-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.js
85 lines (84 loc) · 2.05 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
const path = require('path');
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
module.exports = {
devtool: 'cheap-module-eval-source-map',
entry: {
app: './src/index',
vendor: [
'react',
'react-dom',
'redux',
'react-redux',
'react-router',
'codemirror',
],
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].[chunkhash].js',
},
module: {
loaders: [{
test: /\.jsx?$/,
loaders: ['babel'],
include: path.join(__dirname, 'src'),
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader'),
include: path.join(__dirname, 'src/css'),
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file?name=public/fonts/[name].[ext]',
include: path.join(__dirname, 'src/assets'),
}],
},
plugins: [
new CleanWebpackPlugin(['dist'], {
root: process.cwd(),
}),
new HtmlWebpackPlugin({
template: 'index.ejs',
}),
new ExtractTextPlugin('style.[contenthash].css'),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
comments: false,
compress: {
warnings: false,
unused: true,
dead_code: true,
},
mangle: {
except: ['webpackJsonp'],
},
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'vendor.[chunkhash].js',
minChunks: Infinity,
}),
new CompressionPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0,
}),
],
resolve: {
extensions: ['', '.js', '.jsx', '.css'],
alias: {
react: 'preact-compat',
'react-dom': 'preact-compat',
},
modulesDirectories: [
'node_modules',
],
},
};