@@ -76,20 +76,6 @@ export default class InitGenerator extends Generator {
76
76
tooltip . splitChunks ( )
77
77
) ;
78
78
79
- if ( ! this . usingDefaults ) {
80
- this . dependencies . push ( "terser-webpack-plugin" ) ;
81
- this . configuration . config . topScope . push (
82
- tooltip . terser ( ) ,
83
- "const TerserPlugin = require('terser-webpack-plugin');" ,
84
- "\n"
85
- ) ;
86
- } else {
87
- this . dependencies . push ( "webpack-dev-server" ) ;
88
- this . configuration . config . webpackOptions . devServer = {
89
- open : true
90
- } ;
91
- }
92
-
93
79
( this . configuration . config . webpackOptions . plugins as string [ ] ) . push ( "new webpack.ProgressPlugin()" ) ;
94
80
}
95
81
@@ -151,7 +137,8 @@ export default class InitGenerator extends Generator {
151
137
} ;
152
138
} else {
153
139
this . configuration . config . webpackOptions . output = {
154
- filename : "'bundle.js'"
140
+ filename : "'bundle.js'" ,
141
+ path : `path.resolve(__dirname, '${ outputDir } ')`
155
142
} ;
156
143
}
157
144
@@ -231,8 +218,21 @@ export default class InitGenerator extends Generator {
231
218
( this . configuration . config . webpackOptions . plugins as string [ ] ) . push ( `new ${ htmlwebpackPlugin } ()` ) ;
232
219
}
233
220
234
- let optimizationConfig = getDefaultOptimization ( ! this . usingDefaults ) ;
235
- this . configuration . config . webpackOptions . optimization = optimizationConfig ;
221
+ if ( ! this . usingDefaults ) {
222
+ this . dependencies . push ( "webpack-dev-server" ) ;
223
+ this . configuration . config . webpackOptions . devServer = {
224
+ open : true
225
+ } ;
226
+ } else {
227
+ this . dependencies . push ( "terser-webpack-plugin" ) ;
228
+ this . configuration . config . topScope . push (
229
+ tooltip . terser ( ) ,
230
+ "const TerserPlugin = require('terser-webpack-plugin');" ,
231
+ "\n"
232
+ ) ;
233
+ }
234
+ this . configuration . config . webpackOptions . optimization = getDefaultOptimization ( this . usingDefaults ) ;
235
+ this . configuration . config . webpackOptions . mode = this . usingDefaults ? "'development'" : "'production'" ;
236
236
237
237
done ( ) ;
238
238
}
0 commit comments