forked from hcfyapp/crx-selection-translate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
63 lines (58 loc) · 1.92 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
const webpack = require( 'webpack' ) ,
CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin ,
ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
module.exports = {
entry : {
bg : './src/background-scripts/' ,
content : './src/content-scripts/' ,
options : './src/options/' ,
popup : './src/popup/' ,
'bs-lite' : './src/public/bootstrap-lite.scss'
} ,
output : {
path : './src/bundle' ,
filename : '[name].js'
} ,
module : {
loaders : [
{
test : /\.js$/ ,
exclude : [ /node_modules(?!(\/|\\?\\)(translation\.js|selection-widget)\1)/ ] ,
loader : 'babel' ,
query : {
presets : [ 'es2015' , 'stage-3' ] ,
plugins : [ 'transform-runtime' ]
}
} ,
{
test : /\.html$/ ,
loader : 'vue-html'
} ,
{
test : /\.scss$/ ,
loader : ExtractTextPlugin.extract( 'style-loader' , 'css-loader?sourceMap!sass-loader?sourceMap' )
}
]
} ,
plugins : [
// 模块依赖分布表:
// bg : babel-polyfill chrome-storage-wrapper
// options : babel-polyfill chrome-storage-wrapper vue public/locales.js
// content : babel-polyfill chrome-storage-wrapper vue public/locales.js selection-widget interact.js
// popup : babel-polyfill chrome-storage-wrapper vue public/locales.js selection-widget
// 所以:
// commons3.js 包含 babel-polyfill chrome-storage-wrapper
// commons2.js 包含 vue public/locales.js
// commons1.js 包含 selection-widget
new CommonsChunkPlugin( 'commons1.js' , [ 'content' , 'popup' ] ) ,
new CommonsChunkPlugin( 'commons2.js' , [ 'commons1.js' , 'options' ] ) ,
new CommonsChunkPlugin( 'commons3.js' , [ 'bg' , 'commons2.js' ] ) ,
new ExtractTextPlugin( '[name].css' ) ,
new webpack.DefinePlugin( {
DEBUG : true ,
TEST : false
} )
] ,
watch : true ,
devtool : '#source-map'
};