-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
101 lines (91 loc) · 2.47 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
const webpack = require('webpack');
const path = require('path');
const HOST = process.env.HOST || '0.0.0.0';
const PORT = process.env.PORT || '8880';
const sourcePath = path.join(__dirname, './src');
const staticsPath = path.join(__dirname, './dist');
const plugins = [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'vendor.bundle.js',
minChunks(module, count) {
var context = module.context;
return context && context.indexOf('node_modules') >= 0;
},
}),
];
let jsEntry = ['./src/examples/index.js'];
plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin()
);
module.exports = {
devtool: 'source-map',
entry: {
bundle: jsEntry,
},
output: {
filename: '[name].js',
chunkFilename: '[name]-chunk.js',
path: staticsPath,
publicPath: './',
},
module: {
rules: [
{
test: /\.html$/,
use: {
loader: 'file-loader',
query: {
name: '[name].[ext]'
}
}
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
query: {
cacheDirectory: true,
presets: [['es2015', {modules: false}], 'react', 'stage-0'],
plugins: ['syntax-dynamic-import',]
}
}
]
},
{
test: /\.(gif|png|jpg|jpeg\ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
use: 'file-loader'
}
],
},
resolve: {
extensions: ['.js', '.jsx', '.scss'],
modules: [
sourcePath,
'node_modules'
]
},
plugins: plugins,
devServer: {
contentBase: '.',
publicPath: '/',
historyApiFallback: true,
port: PORT,
host: HOST,
hot: true,
compress: false,
stats: {
colors: true,
chunks: false, // be less verbose
},
},
externals: {
'cheerio': 'window',
'react/addons': true, // important!!
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': true
}
};