-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
46 lines (44 loc) · 1.3 KB
/
webpack.common.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
const path = require('path')
const fs = require('fs')
const webpack = require('webpack')
let nodeModules = fs.readdirSync('./node_modules')
.filter((module) => {
return module !== '.bin';
})
.reduce((prev, module) => {
return Object.assign(prev, {[module]: 'commonjs ' + module});
}, {})
module.exports = {
entry: {
app: './application.js'
},
output: {
path: path.resolve(__dirname, './webpack-build'),
filename: '[name].bundle.js'
},
module: {
rules: [
{ test: /\.jsx$/, loader: 'babel-loader', exclude: /node_modules/ },
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
]
},
target: 'web',
node: {
/* http://webpack.github.io/docs/configuration.html#node */
__dirname: false,
__filename: false
},
watchOptions: {
poll: 1000
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'API_URL': JSON.stringify(process.env.API_URL),
'FILE_SERVER_URL': JSON.stringify(process.env.FILE_SERVER_URL)
}
}),
],
resolve: { alias: { 'react': path.resolve(__dirname, './node_modules', 'react') } }
}