-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.base.config.js
109 lines (105 loc) · 2.62 KB
/
webpack.base.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
const path = require('path');
const {
optimize,
DefinePlugin,
NamedModulesPlugin,
NoEmitOnErrorsPlugin,
} = require('webpack');
const {
CommonsChunkPlugin,
} = optimize;
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const PreloadWebpackPlugin = require('preload-webpack-plugin');
const paths = require('./paths');
module.exports = {
entry: {
vendor: [
'classnames',
'immutable',
'react',
'prop-types',
'react-dom',
'react-redux',
'redux',
'redux-immutable',
'redux-thunk',
'reselect',
'transit-immutable-js',
'whatwg-fetch',
],
},
module: {
rules: [
{
test: /\.jsx?$/,
include: [
paths.app,
],
exclude: /node_modules/,
enforce: 'pre',
loader: 'eslint-loader',
},
{
test: /\.css$/,
loader: 'css-loader',
},
],
},
plugins: [
new CaseSensitivePathsPlugin(),
new HtmlWebpackPlugin({
template: path.join(paths.app, 'index.ejs'),
markup: '<div id="root"></div>',
inject: false,
}),
new HtmlWebpackPlugin({
template: path.join(paths.app, 'index.ejs'),
filename: path.resolve(paths.functions, 'views/index.ejs'),
markup: `
<div id="root"><%- markup %></div>
<% if (state) { %>
<script>window.__PRELOADED_STATE__ = <%- state %></script>
<% } %>
`,
inject: false,
}),
new PreloadWebpackPlugin({
rel: 'preload',
fileBlacklist: [/\.map/, /\.hot-update\.js$/],
include: ['app', 'runtime', 'vendor'],
}),
new DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'__DEV__': process.env.NODE_ENV === 'development',
'__PROD__': process.env.NODE_ENV === 'production',
'__SERVER__': false,
}),
new CommonsChunkPlugin({
name: 'vendor',
minChunks: module => module.resource && (/node_modules/).test(module.resource),
}),
new CommonsChunkPlugin({
chunks: ['analytics'],
async: 'async-analytics',
minChunks: module => module.resource && (/node_modules/).test(module.resource),
}),
new CommonsChunkPlugin({ name: 'runtime' }),
new NamedModulesPlugin(),
new NoEmitOnErrorsPlugin(),
],
resolve: {
alias: {
assets: paths.assets,
components: paths.components,
containers: paths.containers,
pages: paths.pages,
store: paths.store,
},
extensions: ['.js', '.jsx'],
},
stats: {
colors: true,
reasons: true,
},
};