-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
85 lines (82 loc) · 3.05 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// the html plugin will dynamically add the bundle script tags to the main index.html file
// it also allows us to use template to build the rest of that file
var HtmlWebpackPlugin = require('html-webpack-plugin')
var webpack = require('webpack')
// FIXME: how to vary this per build ...
//require('dotenv').config({path: '/custom/path/to/your/env/vars'});
var environment = process.env.NODE_ENV || 'development'
console.log(environment)
// FIXME: how to vary this per build ...
//require('dotenv').config({path: '/custom/path/to/your/env/vars'});
var config = require('dotenv').config({path: __dirname + '/.env.'+ environment})
// FIXME: should we define a BASE_URL, so we can link correctly on acceptance
//
// can do this too:
// node -r dotenv/config your_script.js dotenv_config_path=/custom/path/to/your/env/vars
// (see) https://www.npmjs.com/package/dotenv#preload
//
module.exports = {
// start an main.js and follow requires to build the 'app' bundle in the 'dist' directory
entry: {
app: ['babel-polyfill', "./src/main.js"]
},
// put all built files in dist
// use 'name' variable to make
// bundles named after the entryoints
// above
output: {
path: __dirname + "/dist/",
filename: "[name].js",
library: "ScholarsSearch",
libraryTarget: "umd"
},
// NOTE: this is in here so nock can run tests - but they don't work anyway
//node: {
// fs: "empty"
//},
module: {
loaders: [
{ test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/, loader: 'file-loader' },
// style pre-processing
{ test: /\.less$/, loader: 'style-loader!css-loader!less-loader' }, // use ! to chain loaders
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{ test: /\.(png|gif|jpg)$/, loader: 'file-loader' },
{ test: /jquery/, loader: 'expose?$!expose?jQuery' },
{ test: /\.json$/, loader: 'json' },
// react/jsx and es6/2015 transpiling
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
// http://asdfsafds.blogspot.com/2016/02/referenceerror-regeneratorruntime-is.html
// http://stackoverflow.com/questions/33527653/babel-6-regeneratorruntime-is-not-defined-with-async-await
query: {
presets: ['react','es2015'],
plugins: ["transform-runtime"]
}
}
]
},
// make sourcemaps in separate files
devtool: 'source-map',
plugins: [
// build index from template, add cach-busting hashes to js bundle urls
// pass title variable to the template - you can specify any property here
// and access it in the src/index.ejs template
// inject: 'head',
// hash: true,
// title: "Calendar Demo",
// template: 'src/index.ejs/'
new HtmlWebpackPlugin({
inject: 'head',
hash: true,
title: "Scholars Search",
template: 'src/index.ejs/'
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(environment),
'process.env.SOLR_URL': JSON.stringify(process.env.SOLR_URL),
'process.env.ORG_URL': JSON.stringify(process.env.ORG_URL)
})
]
}