Skip to content

Commit a16bcca

Browse files
refactor(template): generate a template with less empty lines
1 parent 4604c7d commit a16bcca

1 file changed

Lines changed: 9 additions & 21 deletions

File tree

packages/create-webpack-app/templates/init/vue/webpack.config.tpl

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,10 @@ import WorkboxWebpackPlugin from "workbox-webpack-plugin";<% } %>
1111

1212
const __filename = fileURLToPath(import.meta.url);
1313
const __dirname = path.dirname(__filename);
14-
const isProduction = process.env.NODE_ENV === "production";
15-
<% if (cssType !== "none") { %>
16-
<% if (extractPlugin === "Yes") { %>
17-
const stylesHandler = MiniCssExtractPlugin.loader;
18-
<% } else if (extractPlugin === "Only for Production") { %>
19-
const stylesHandler = isProduction ? MiniCssExtractPlugin.loader : "vue-style-loader";
20-
<% } else { %>
21-
const stylesHandler = "vue-style-loader";
22-
<% } %>
23-
<% } %>
14+
const isProduction = process.env.NODE_ENV === "production";<% if (cssType !== "none") { %><% if (extractPlugin === "Yes") { %>
15+
const stylesHandler = MiniCssExtractPlugin.loader;<% } else if (extractPlugin === "Only for Production") { %>
16+
const stylesHandler = isProduction ? MiniCssExtractPlugin.loader : "vue-style-loader";<% } else { %>
17+
const stylesHandler = "vue-style-loader";<% } %><% } %>
2418

2519
/** @type {import("webpack").Configuration} */
2620
const config <% if (langType === "Typescript") { %>: Configuration <% } %>= {
@@ -35,10 +29,8 @@ const config <% if (langType === "Typescript") { %>: Configuration <% } %>= {
3529
new VueLoaderPlugin(),<% if (htmlWebpackPlugin) { %>
3630
new HtmlWebpackPlugin({
3731
template: "index.html",
38-
}),
39-
<% } %><% if (extractPlugin === "Yes") { %>
40-
new MiniCssExtractPlugin(),
41-
<% } %>
32+
}),<% } %><% if (extractPlugin === "Yes") { %>
33+
new MiniCssExtractPlugin(),<% } %>
4234
// Add your plugins here
4335
// Learn more about plugins from https://webpack.js.org/configuration/plugins/
4436
],
@@ -105,13 +97,9 @@ const config <% if (langType === "Typescript") { %>: Configuration <% } %>= {
10597

10698
export default () => {
10799
if (isProduction) {
108-
config.mode = "production";
109-
<% if (extractPlugin === "Only for Production") { %>
110-
config.plugins.push(new MiniCssExtractPlugin());
111-
<% } %>
112-
<% if (workboxWebpackPlugin) { %>
113-
config.plugins.push(new WorkboxWebpackPlugin.GenerateSW());
114-
<% } %>
100+
config.mode = "production";<% if (extractPlugin === "Only for Production") { %>
101+
config.plugins.push(new MiniCssExtractPlugin());<% } %><% if (workboxWebpackPlugin) { %>
102+
config.plugins.push(new WorkboxWebpackPlugin.GenerateSW());<% } %>
115103
} else {
116104
config.mode = "development";
117105
}

0 commit comments

Comments
 (0)