11// Generated using webpack-cli https://github.com/webpack/webpack-cli
22
3- const path = require('path');<% if (htmlWebpackPlugin) { %>
4- const HtmlWebpackPlugin = require(' html-webpack-plugin' );<% } %><% if (extractPlugin !== 'No') { %>
5- const MiniCssExtractPlugin = require(' mini-css-extract-plugin' );<% } %><% if (workboxWebpackPlugin) { %>
6- const WorkboxWebpackPlugin = require(' workbox-webpack-plugin' );<% } %>
3+ import path from "node:path";
4+ import { fileURLToPath } from "node:url";<% if (htmlWebpackPlugin) { %>
5+ import HtmlWebpackPlugin from " html-webpack-plugin" ;<% } %><% if (extractPlugin !== "No") { %>
6+ import MiniCssExtractPlugin from " mini-css-extract-plugin" ;<% } %><% if (workboxWebpackPlugin) { %>
7+ import WorkboxWebpackPlugin from " workbox-webpack-plugin" ;<% } %>
78
8- const isProduction = process.env.NODE_ENV === 'production';
9- <% if (cssType !== 'none') { %>
9+ const __filename = fileURLToPath(import.meta.url);
10+ const __dirname = path.dirname(__filename);
11+ const isProduction = process.env.NODE_ENV === "production";
12+ <% if (cssType !== "none") { %>
1013<% if (extractPlugin === " Yes" ) { %>
1114const stylesHandler = MiniCssExtractPlugin.loader;
1215<% } else if (extractPlugin === "Only for Production") { %>
13- const stylesHandler = isProduction ? MiniCssExtractPlugin.loader : ' style-loader' ;
16+ const stylesHandler = isProduction ? MiniCssExtractPlugin.loader : " style-loader" ;
1417<% } else { %>
15- const stylesHandler = ' style-loader' ;
18+ const stylesHandler = " style-loader" ;
1619<% } %>
1720<% } %>
1821
1922/** @type { import(" webpack" ).Configuration} */
2023const config = {
21- entry: ' <%= entryPoint %>' ,
24+ entry: " <%= entryPoint %>" ,
2225 output: {
23- path: path.resolve(__dirname, ' dist' ),
26+ path: path.resolve(__dirname, " dist" ),
2427 } ,<% if (devServer) { %>
2528 devServer: {
2629 open: true ,
27- host: ' localhost' ,
30+ host: " localhost" ,
2831 } ,<% } %>
2932 plugins: [<% if (htmlWebpackPlugin) { %>
3033 new HtmlWebpackPlugin({
31- template: ' index.html' ,
34+ template: " index.html" ,
3235 } ),
3336<% } %><% if (extractPlugin === "Yes") { %>
3437 new MiniCssExtractPlugin(),
@@ -40,63 +43,63 @@ const config = {
4043 rules: [<% if (langType == " ES6" ) { %>
4144 {
4245 test: /\.(js|jsx)$/i,
43- loader: ' babel-loader' ,
46+ loader: " babel-loader" ,
4447 } ,<% } %><% if (langType == "Typescript") { %>
4548 {
4649 test: /\.(ts|tsx)$/i,
47- loader: ' ts-loader' ,
48- exclude: [' /node_modules/' ],
50+ loader: " ts-loader" ,
51+ exclude: [" /node_modules/" ],
4952 } ,<% } %><% if (isCSS && !isPostCSS) { %>
5053 {
5154 test: /\.css$/i,
52- use: [stylesHandler,' css-loader' ],
53- } ,<% } %><% if (cssType == ' SASS' ) { %>
55+ use: [stylesHandler," css-loader" ],
56+ } ,<% } %><% if (cssType == " SASS" ) { %>
5457 {
5558 test: /\.s[ac]ss$/i,
56- use: [stylesHandler, ' css-loader' , <% if (isPostCSS) { %> ' postcss-loader' , <% } %>' sass-loader' ],
57- },<% } %><% if (cssType == ' LESS' ) { %>
59+ use: [stylesHandler, " css-loader" , <% if (isPostCSS) { %> " postcss-loader" , <% } %>" sass-loader" ],
60+ },<% } %><% if (cssType == " LESS" ) { %>
5861 {
5962 test: /\.less$/i,
60- use: [stylesHandler, ' css-loader' , <% if (isPostCSS) { %> ' postcss-loader' , <% } %>' less-loader' ],
61- },<% } %><% if (cssType == ' Stylus' ) { %>
63+ use: [stylesHandler, " css-loader" , <% if (isPostCSS) { %> " postcss-loader" , <% } %>" less-loader" ],
64+ },<% } %><% if (cssType == " Stylus" ) { %>
6265 {
6366 test: /\.styl$/i,
64- use: [stylesHandler, ' css-loader' , <% if (isPostCSS) { %> ' postcss-loader' , <% } %>' stylus-loader' ],
67+ use: [stylesHandler, " css-loader" , <% if (isPostCSS) { %> " postcss-loader" , <% } %>" stylus-loader" ],
6568 },<% } %><% if (isPostCSS && isCSS) { %>
6669 {
6770 test: /\.css$/i,
68- use: [stylesHandler, ' css-loader' , ' postcss-loader' ],
71+ use: [stylesHandler, " css-loader" , " postcss-loader" ],
6972 } ,<% } %>
7073 {
7174 test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
72- type: ' asset' ,
75+ type: " asset" ,
7376 } ,
7477 %><% if (htmlWebpackPlugin) { %>
7578 {
7679 test: /\.html$/i,
77- use: [' html-loader' ],
80+ use: [" html-loader" ],
7881 } ,<% } %>
7982
8083 // Add your rules for custom modules here
8184 // Learn more about loaders from https://webpack.js.org/loaders/
8285 ],
8386 },<% if (langType == "Typescript") {% >
8487 resolve: {
85- extensions: [' .tsx' , ' .ts' , ' .jsx' , ' .js' , ' ...' ],
88+ extensions: [" .tsx" , " .ts" , " .jsx" , " .js" , " ..." ],
8689 } ,<% } %>
8790};
8891
89- module.exports = () => {
92+ export default () => {
9093 if (isProduction) {
91- config.mode = ' production' ;
94+ config.mode = " production" ;
9295 <% if (extractPlugin === " Only for Production" ) { %>
9396 config.plugins.push(new MiniCssExtractPlugin());
9497 <% } %>
9598 <% if (workboxWebpackPlugin) { %>
9699 config.plugins.push(new WorkboxWebpackPlugin.GenerateSW());
97100 <% } %>
98101 } else {
99- config.mode = ' development' ;
102+ config.mode = " development" ;
100103 }
101104 return config;
102105};
0 commit comments