This repository has been archived by the owner on Oct 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
71 lines (65 loc) · 1.63 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
68
69
70
71
//@flow
'use strict';
const UglifyPlugin = require('webpack/lib/optimize/UglifyJsPlugin');
const OccurenceOrderPlugin = require('webpack/lib/optimize/OccurrenceOrderPlugin');
const DedupePlugin = require('webpack/lib/optimize/DedupePlugin');
const AggressiveMergingPlugin = require('webpack/lib/optimize/AggressiveMergingPlugin');
const HotModuleReplacementPlugin = require('webpack/lib/HotModuleReplacementPlugin');
const DefinePlugin = require('webpack/lib/DefinePlugin');
const merge = require('webpack-merge');
const base = {
plugins: [
new OccurenceOrderPlugin(),
new DedupePlugin(),
new AggressiveMergingPlugin()
],
entry: {
app: './assets/js/app'
},
output: {
path: `${__dirname}/public/js`,
publicPath: '/js',
filename: '[name].js'
},
resolve: {
extensions: ['', '.js'],
fallback: ['node_modules']
},
resolveLoader: {
fallback: ['node_modules']
},
module: {
loaders: [{
test: /\.js$/,
loader: 'babel'
}]
}
};
const dev = merge.smart({
entry: {
app: ['webpack-dev-server/client?http://localhost:8080/']
},
devtool: 'inline-source-map',
debug: true,
plugin: [
new HotModuleReplacementPlugin()
]
}, base);
const production = merge.smart({
devtool: 'source-map',
plguins: [
new UglifyPlugin({
minimize: true
}),
new DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})
]
}, base);
module.exports = {
base,
dev,
production
};