-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.js
66 lines (63 loc) · 1.66 KB
/
webpack.prod.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
/* eslist-disable */
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin')
const PATHS = {
src: path.join(__dirname, 'src'),
app: path.join(__dirname, 'src/app.js'),
dist: path.join(__dirname, 'dist')
};
var webpackconfig = {
devtool: 'source-map',
entry: {
app: [
PATHS.app
],
vendor: [
'react',
'react-dom',
'react-router',
'redux',
'react-redux',
'reselect',
'lodash',
]
},
output: {
path: PATHS.dist,
filename: '[name].[chunkhash].js', // Hashed output name
publicPath: '/',
},
module: {
loaders: [
{
test: /\.js$/, // Javascript loader
include: PATHS.src,
exclude: /node_modules/,
loader: 'babel',
query: {
cacheDirectory: true, // Dont transpile again if nothing has changed
presets: [ 'es2015', 'es2016', 'react' ], // Support ES7
plugins: [
'babel-plugin-transform-object-rest-spread', // Adds ... spread operator for objects
'babel-plugin-transform-class-properties', // Adds support for React classes
]
}
},
{
test: /\.css/,
loaders: ['style', 'css'],
include: PATHS.src,
exclude: /node_modules/,
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(PATHS.src, 'index.html'), // Use index.html as template for index.html
chunksSortMode: 'dependency', // Order the dependacy so that bundle comes first
filename: 'index.html', // Output file name
inject: 'body', // Enject into the end of the body tag
}),
]
}
module.exports = webpackconfig