-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
67 lines (63 loc) · 1.35 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
const os = require('os');
const path = require('path');
const webpack = require('webpack');
const HappyPack = require('happypack');
const happyThreadPool = HappyPack.ThreadPool({
size: os.cpus().length
});
const options = require('./webpack.options.js');
module.exports = {
entry: options.entry,
output: {
path: options.output,
filename: '[name].js'
},
module: {
loaders: [
// css
{
test: /^.*\.css$/,
loader: 'happypack/loader?id=css_loader'
},
// sass
{
test: /^.*\.sass$/,
loader: 'happypack/loader?id=sass_loader'
},
// react
{
test: /^.*\.js$/,
loader: 'happypack/loader?id=react_loader'
}
]
},
plugins: [
/* 允许错误不打断程序 */
new webpack.NoEmitOnErrorsPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor'
}),
/* HappyPack */
// sass
new HappyPack({
id: 'sass_loader',
loaders: ['style-loader!raw-loader!sass-loader'],
threadPool: happyThreadPool,
cache: true,
verbose: true
}),
// react
new HappyPack({
id: 'react_loader',
loaders: [{
path: 'babel-loader',
query: {
presets: ['react']
}
}],
threadPool: happyThreadPool,
cache: true,
verbose: true
})
]
};