forked from PowerUpWithPride/donation-tracker-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtracker.webpack.js
executable file
·47 lines (43 loc) · 1.53 KB
/
tracker.webpack.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
var path = require('path');
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var sharedConfig = require('./shared.webpack');
module.exports = function(opts) {
var config = {
context: __dirname,
entry: ['./js/init', './js'],
output: {
'filename': 'public-[name]-[hash].js',
'pathinfo': opts.context.DEBUG,
},
externals: sharedConfig(opts).externals,
module: sharedConfig(opts).module,
postcss: [autoprefixer],
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(
opts.context.DEBUG ? 'development' : 'production'
)
},
__DEVTOOLS__: opts.context.DEBUG
})
],
devtool: opts.context.DEBUG ? 'eval-source-map' : 'source-map'
};
if (!opts.hmr) {
// Move css assets into separate files
config.plugins.push(new ExtractTextPlugin('[name]-[contenthash].css'));
}
if (!opts.context.DEBUG) {
// Remove duplicates and activate compression
config.plugins.push(
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({comments: false})
);
}
return config;
};