forked from lshearer/browser-tools-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-webpack-config.js
130 lines (116 loc) · 2.92 KB
/
make-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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
var webpack = require('webpack');
var path = require('path');
var config = require('./config');
module.exports = function makeWebpackConfig(options) {
options = options || {
debug: false
};
var debug = options.debug;
var minify = !debug;
var devtool = minify ? 'source-map' : undefined;
var svgoConfig = JSON.stringify({
plugins: [
{
removeTitle: true
},
{
convertColors: {
shorthex: false
}
},
{
convertPathData: false
}
]
});
var autoPrefixerConfig = JSON.stringify({
browsers: ["last 2 versions", "ie >= 9"]
});
var plugins = [];
if (minify) {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
sourcemaps: true,
})
);
}
plugins.push(new webpack.optimize.CommonsChunkPlugin({
// pull out common modules from async dependencies of `loader` entry point chunk
name: "loader",
children: true,
async: true,
}));
plugins.push(new webpack.DefinePlugin({
VERSION: JSON.stringify(require('./package.json').version)
}));
return {
// configuration
entry: {
'loader': './src/loader',
'popup-connector': './src/connectors/popup-connector',
'dev-tools-panel-connector': './src/connectors/dev-tools-panel-connector'
},
externals: {
// 'underscore': {
// commonjs: 'underscore',
// commonjs2: 'underscore',
// amd: 'underscore',
// root: '_',
// },
// 'jquery-external': {
// commonjs: 'jquery',
// commonjs2: 'jquery',
// amd: 'jquery',
// root: 'jQuery',
// },
},
output: {
filename: '[name].js',
chunkFilename: 'chunks/[name]' + (debug ? '' : '.[chunkhash]') + '.js',
// sourceMapFilename: '[file].map.js',
path: path.resolve(__dirname, 'dist'),
library: config.globalExportPrefix + '-[name]',
libraryTarget: 'umd',
umdNamedDefine: true,
pathinfo: !minify,
},
module: {
// TODO - get this working as a loader; isn't reporting any errors right now though
// preloaders: [
// {
// test: /\.jsx?$/,
// loader: 'eslint',
// exclude: /node_modules/
// }
// ],
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
// loader: 'babel?stage=2'
loader: 'babel?stage=2&optional[]=runtime'
},
{
test: /\.scss$/,
loader: 'style!css!autoprefixer?' + autoPrefixerConfig + '!sass'
},
{
test: /\.svg$/,
loader: 'raw!svgo?' + svgoConfig
},
{
test: /\.jpe?g$/,
loader: 'url?limit=10000'
}
]
},
plugins: plugins,
devtool: devtool,
// eslint: {
// configFile: path.resolve('./.eslintrc')
// }
};
}