/
webpack.config.prod.js
97 lines (96 loc) · 2.5 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
93
94
95
96
97
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const InlineChunkWebpackPlugin = require('html-webpack-inline-chunk-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
module.exports = {
entry: {
main: './app/js/app.jsx',
vendor: [
'react',
'react-dom',
],
},
output: {
path: path.join(__dirname, 'dist', 'assets'),
filename: '[name].[chunkhash].js',
publicPath: '/assets/',
},
resolve: {
extensions: ['.js', '.jsx'],
modules: [
path.resolve('./app'),
path.resolve('./app/js'),
'node_modules',
],
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
new webpack.optimize.CommonsChunkPlugin({ name: ['vendor', 'mainfest'], minChunks: Infinity }),
new webpack.optimize.CommonsChunkPlugin({ async: true, minChunks: 2 }),
new webpack.optimize.MinChunkSizePlugin({ minChunkSize: 8192 }),
new HtmlWebpackPlugin({
title: 'Assignment Tracker',
filename: '../index.html',
template: './app/index.ejs',
}),
new InlineChunkWebpackPlugin({
inlineChunks: ['manifest'],
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true,
warnings: false,
},
mangle: {
screw_ie8: true,
},
output: {
comments: false,
screw_ie8: true,
},
sourceMap: false,
}),
new ExtractTextPlugin({
filename: '[name].[chunkhash].css',
allChunks: true,
}),
...process.env.DEBUG ? [new BundleAnalyzerPlugin({
analyzerMode: 'server',
})] : [],
],
module: {
rules: [
{
test: /\.jsx?$/,
loaders: ['babel-loader'],
exclude: /node_modules/,
},
{
test: /\.md$/,
loaders: ['raw-loader'],
},
{
test: /\.s?css$/,
loader: ExtractTextPlugin.extract(['css-loader', 'resolve-url-loader', 'sass-loader']),
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff',
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader',
},
{
test: /\.(gif|png|jpg|jpeg)(\?[a-z0-9]+)?$/,
loader: 'url-loader?limit=8192',
},
],
},
};