@@ -155,53 +155,49 @@ export default class InitGenerator extends Generator {
155155 "No" ,
156156 this . autoGenerateConfig
157157 ) ;
158-
159- if ( this . langType === "No" && stylingType === "No" ) {
158+ if ( this . langType === "No" ) {
160159 this . usingDefaults = true ;
161160 }
162-
163161 const { ExtractUseProps, regExpForStyles } = styleQuestionHandler ( self , stylingType ) ;
162+ if ( stylingType !== "No" ) {
163+ this . usingDefaults = false ;
164+ }
165+ // Ask if the user wants to use extractPlugin
166+ const { useExtractPlugin } = await Input (
167+ self ,
168+ "useExtractPlugin" ,
169+ "If you want to bundle your CSS files, what will you name the bundle? (press enter to skip)" ,
170+ "main" ,
171+ this . autoGenerateConfig
172+ ) ;
164173
165- if ( ! this . usingDefaults ) {
166- // Ask if the user wants to use extractPlugin
167- const { useExtractPlugin } = await Input (
168- self ,
169- "useExtractPlugin" ,
170- "If you want to bundle your CSS files, what will you name the bundle? (press enter to skip)" ,
171- "'main.css'" ,
172- this . autoGenerateConfig
174+ if ( regExpForStyles ) {
175+ const cssBundleName : string = useExtractPlugin ;
176+ this . dependencies . push ( "mini-css-extract-plugin" ) ;
177+ this . configuration . config . topScope . push (
178+ tooltip . cssPlugin ( ) ,
179+ "const MiniCssExtractPlugin = require('mini-css-extract-plugin');" ,
180+ "\n"
173181 ) ;
182+ if ( cssBundleName . length !== 0 ) {
183+ ( this . configuration . config . webpackOptions . plugins as string [ ] ) . push (
184+ // TODO: use [contenthash] after it is supported
185+ `new MiniCssExtractPlugin({ filename:'${ cssBundleName } .[chunkhash].css' })`
186+ ) ;
187+ } else {
188+ ( this . configuration . config . webpackOptions . plugins as string [ ] ) . push (
189+ "new MiniCssExtractPlugin({ filename:'style.css' })"
190+ ) ;
191+ }
174192
175- if ( regExpForStyles ) {
176- if ( this . isProd ) {
177- const cssBundleName : string = useExtractPlugin ;
178- this . dependencies . push ( "mini-css-extract-plugin" ) ;
179- this . configuration . config . topScope . push (
180- tooltip . cssPlugin ( ) ,
181- "const MiniCssExtractPlugin = require('mini-css-extract-plugin');" ,
182- "\n"
183- ) ;
184- if ( cssBundleName . length !== 0 ) {
185- ( this . configuration . config . webpackOptions . plugins as string [ ] ) . push (
186- // TODO: use [contenthash] after it is supported
187- `new MiniCssExtractPlugin({ filename:'${ cssBundleName } .[chunkhash].css' })`
188- ) ;
189- } else {
190- ( this . configuration . config . webpackOptions . plugins as string [ ] ) . push (
191- "new MiniCssExtractPlugin({ filename:'style.css' })"
192- ) ;
193- }
194-
195- ExtractUseProps . unshift ( {
196- loader : "MiniCssExtractPlugin.loader"
197- } ) ;
198- }
193+ ExtractUseProps . unshift ( {
194+ loader : "MiniCssExtractPlugin.loader"
195+ } ) ;
199196
200- this . configuration . config . webpackOptions . module . rules . push ( {
201- test : regExpForStyles ,
202- use : ExtractUseProps
203- } ) ;
204- }
197+ this . configuration . config . webpackOptions . module . rules . push ( {
198+ test : regExpForStyles ,
199+ use : ExtractUseProps
200+ } ) ;
205201 }
206202 if ( this . usingDefaults ) {
207203 // Html webpack Plugin
0 commit comments