@@ -15,10 +15,10 @@ module.exports = function(env) {
15
15
16
16
process . env . BABEL_ENV = isDev ? 'development' : 'production'
17
17
18
- let config = {
18
+ return {
19
19
context : root ,
20
20
21
- devtool : 'source-map' ,
21
+ devtool : isDev ? 'cheap-module-inline-source-map' : 'source-map' ,
22
22
23
23
entry : {
24
24
application : [ './app/boot.js' ]
@@ -38,84 +38,31 @@ module.exports = function(env) {
38
38
} ,
39
39
40
40
module : {
41
- loaders : [
41
+ rules : [
42
42
{
43
- test : / \. j s x * / ,
43
+ test : / \. j s $ / ,
44
44
loader : 'babel-loader' ,
45
45
exclude : / n o d e _ m o d u l e s / ,
46
46
options : {
47
- cacheDirectory : '.babel-cache' ,
48
- plugins : [
49
- 'react-hot-loader/babel' ,
50
- [ 'transform-runtime' , { polyfill : false } ]
51
- ]
47
+ plugins : [ [ 'transform-runtime' , { polyfill : false } ] ]
52
48
}
53
49
}
54
50
]
55
51
} ,
56
52
57
53
plugins : [
58
- new Webpack . DefinePlugin ( {
59
- 'process.env.NODE_ENV' : JSON . stringify (
60
- isDev ? 'development' : 'production'
61
- )
62
- } ) ,
63
54
new HtmlWebpackPlugin ( {
64
55
inject : true ,
65
56
template : resolve ( root , 'public/index.html' )
66
- } ) ,
67
- new Webpack . optimize . CommonsChunkPlugin ( {
68
- name : 'vendor' ,
69
- minChunks : function ( module ) {
70
- var context = module . context
71
-
72
- if ( context == null ) {
73
- return false
74
- }
75
-
76
- return (
77
- context . includes ( 'node_modules' ) ||
78
- context . includes ( 'microcosm/src' )
79
- )
80
- }
81
57
} )
82
58
] ,
83
59
84
- node : {
85
- global : true ,
86
- console : false ,
87
- process : false ,
88
- Buffer : false ,
89
- __filename : 'mock' ,
90
- __dirname : 'mock' ,
91
- setImmediate : false
92
- } ,
93
-
94
60
devServer : {
95
- hot : isDev ,
96
61
contentBase : resolve ( root , 'public' ) ,
97
62
publicPath : '/' ,
98
63
compress : true ,
99
64
historyApiFallback : true ,
100
65
port : PORT
101
66
}
102
67
}
103
-
104
- if ( isDev ) {
105
- config . devtool = 'cheap-module-inline-source-map'
106
-
107
- config . entry [ 'application' ] . unshift ( 'react-hot-loader/patch' )
108
-
109
- config . entry [ 'dev' ] = [
110
- 'webpack-dev-server/client?http://localhost:' + PORT ,
111
- 'webpack/hot/only-dev-server'
112
- ]
113
-
114
- config . plugins . unshift (
115
- new Webpack . HotModuleReplacementPlugin ( ) ,
116
- new Webpack . NamedModulesPlugin ( )
117
- )
118
- }
119
-
120
- return config
121
68
}
0 commit comments