-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
112 lines (107 loc) · 2.88 KB
/
webpack.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
110
111
112
const dev = process.env.NODE_ENV !== 'production' && process.argv.indexOf('-p') === -1;
const usePreact = false;
const path = require('path');
const glob = require('glob');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const PurifyCSSPlugin = require('purifycss-webpack');
const AssetsPlugin = require('assets-webpack-plugin');
const config = {
devServer: {
host: 'localhost',
port: '8081',
historyApiFallback: true,
hot: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
},
devtool: dev ? 'eval' : false,
entry: dev ? {
main: [
'webpack-dev-server/client?http://localhost:8081',
'react-hot-loader/patch',
path.join(__dirname, '/src/client/index.jsx'),
],
} : {
main: path.join(__dirname, '/src/client/index.jsx'),
},
output: {
publicPath: 'http://localhost:8081/',
path: path.join(__dirname, '/dist/public'),
filename: dev ? '[name].js' : '[name]-[chunkhash].js',
},
stats: {
colors: true,
reasons: false,
chunks: false,
progress: true,
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.styl$/,
use: dev ? ['style-loader', 'css-loader', 'postcss-loader', 'stylus-loader'] :
ExtractTextPlugin.extract([
{
loader: 'css-loader',
options: { minimize: false },
},
'postcss-loader',
'stylus-loader',
]),
},
],
},
resolve: {
extensions: ['.js', '.jsx'],
alias: usePreact ? {
react: 'preact-compat',
'react-dom': 'preact-compat',
'react-addons-css-transition-group': 'rc-css-transition-group',
'preact-compat': 'preact-compat/dist/preact-compat',
} : {},
},
plugins: dev ? [
new webpack.NamedModulesPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: ({ resource }) => /node_modules/.test(resource),
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'runtime',
}),
new AssetsPlugin({
fullPath: false,
}),
new webpack.HotModuleReplacementPlugin(),
] : [
new webpack.HashedModuleIdsPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: ({ resource }) => /node_modules/.test(resource),
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'runtime',
}),
new ExtractTextPlugin('style-[contenthash].css'),
new PurifyCSSPlugin({
paths: glob.sync(path.join(__dirname, '/src/client/**/*.jsx'), { nodir: true }),
minimize: true,
purifyOptions: {
info: true,
rejected: false,
whitelist: ['auth0-lock-header-logo', 'auth0-lock-widget'],
},
}),
new AssetsPlugin({
fullPath: false,
}),
],
};
module.exports = config;