-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathwebpack.config.js
67 lines (55 loc) · 1.32 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
/**
* Follows
* https://webpack.js.org/guides/hmr-react/
*/
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { resolve } = require('path')
const PORT = process.env.PORT || 3000
module.exports = function(env) {
let isDev = env !== 'production'
let root = process.cwd()
process.env.BABEL_ENV = isDev ? 'development' : 'production'
return {
context: root,
devtool: isDev ? 'cheap-module-inline-source-map' : 'source-map',
entry: {
application: ['./app/boot.js']
},
output: {
filename: '[name].[hash].js',
path: resolve(root, 'build'),
publicPath: '/'
},
resolve: {
alias: {
microcosm$: resolve(__dirname, '../src/index.js'),
microcosm: resolve(__dirname, '../src/')
}
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
plugins: [['transform-runtime', { polyfill: false }]]
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
inject: true,
template: resolve(root, 'public/index.html')
})
],
devServer: {
contentBase: resolve(root, 'public'),
publicPath: '/',
compress: true,
historyApiFallback: true,
port: PORT
}
}
}