-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
77 lines (72 loc) · 1.69 KB
/
webpack.config.js
File metadata and controls
77 lines (72 loc) · 1.69 KB
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
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const config = require('./src/config/environment')
const plugins = [
new webpack.DefinePlugin({
'__DEV__': JSON.stringify(config.isDev)
})
]
let devtool
const entry = {
'chromereload': [config.CHROMERELOAD],
'contentscript': config.CONTENTSCRIPT_PATH
}
let externals = []
const modules = {
preLoaders: [{
test: /\.js$/,
loader: 'eslint',
exclude: /node_modules/
}],
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' },
{ test: /\.json$/, loader: 'json' },
{ test: /\.css?$/, loader: ExtractTextPlugin.extract('style', 'css') },
{ test: /\.styl$/, loader: ExtractTextPlugin.extract('style', 'css!stylus') },
{ test: /\.worker\.js?$/, loaders: ['worker?name=workers/[name].[ext]', 'babel'] },
{ test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
loader: 'file',
query: {
name: 'assets/[name].[hash:8].[ext]'
}
}
]
}
const resolve = {
extensions: ['', '.js', '.css', '.styl']
}
const resolveLoader = {
root: config.MODULES_PATH
}
const output = {
path: config.BUILD_PATH,
publicPath: '/',
filename: '[name].js'
}
if (config.isProd) {
plugins.push(
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
}),
new ExtractTextPlugin('[name].css')
)
} else {
devtool = 'cheap-module-source-map'
plugins.push(
new ExtractTextPlugin('[name].css')
)
}
module.exports = {
watch: config.isDev,
devtool,
entry,
output,
externals,
module: modules,
plugins,
resolve,
resolveLoader
}