-
Notifications
You must be signed in to change notification settings - Fork 31
/
webpack.config.prod.js
92 lines (90 loc) · 3.24 KB
/
webpack.config.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
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
var path = require('path');
var webpack = require('webpack')
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
mode: "production",
devtool: 'source-map',
entry: {
app: [
'./client/app/app.js',
],
auth: [
'./client/auth/app.js',
],
landing: [
'./client/landing/app.js',
],
},
output: {
filename: '[name].[hash].bundle.js',
chunkFilename: '[id].[hash].bundle.js',
path: path.join(__dirname, 'public'),
publicPath: '/static/'
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
function() {
this.plugin("done", function(stats) {
require("fs").writeFileSync(
path.join(__dirname, "stats.json"),
JSON.stringify(stats.toJson()));
});
},
new webpack.LoaderOptionsPlugin({
options: {
sassLoaders: {
includePaths: [
path.resolve(__dirname, './client/scss'),
path.resolve(__dirname, './public'),
]
}
}
}),
new webpack.optimize.AggressiveMergingPlugin(),
// new BundleAnalyzerPlugin()
],
module: {
rules: [
{
test: /\.jsx?$/,
loaders: ['babel-loader'],
exclude: /(node_modules|bower_components)/,
// include: path.join(__dirname, 'client')
},
{ test: /\.css$/, loaders: ['style-loader', 'css-loader'] },
{
test: /\.scss$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "sass-loader",
options: {
includePaths: [
path.resolve(__dirname, './client/scss'),
path.resolve(__dirname, './public'),
]
}
}]
},
{ test: /\.(png|jpg)$/, loader: 'file-loader?name=images/[name].[hash].[ext]' },
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?name=fonts/[name].[hash].[ext]&mimetype=application/font-woff'},
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,loader: 'file-loader?name=fonts/[name].[hash].[ext]&mimetype=application/font-woff'},
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?name=fonts/[name].[hash].[ext]&mimetype=application/octet-stream'},
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?name=fonts/[name].[hash].[ext]'},
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?name=images/[name].[hash].[ext]&mimetype=image/svg+xml' }
]
},
resolve: {
alias: {
styles: path.join(__dirname, './client/scss'),
util: path.join(__dirname, './client/util'),
QueryLink: path.join(__dirname, './client/util/QueryLink.js'),
},
},
}