const CopyPlugin = require("copy-webpack-plugin"); const { glob } = require("glob"); const path = require("path"); let config = { entry: glob.sync(path.resolve("./assets/js/specific/*.js")).reduce((obj, elem) => { let name = elem.substr(path.resolve("./assets/js/").length); name = name.substring(0, name.length - path.extname(name).length); obj[name] = elem; return obj; }, { site: [path.resolve("./assets/js/main.js"), path.resolve("./assets/scss/main.scss")], }), output: { filename: "[name].js", path: path.resolve("./wwwroot/js"), }, module: { rules: [ { test: /\.s[ac]ss$/i, use: [ "style-loader", "css-loader", "sass-loader", ], }, { test: /\.m?js$/, exclude: /(node_modules|bower_components)/, use: { loader: "babel-loader", options: { presets: ["@babel/preset-env"] } } }, { test: /\.(png|svg|jpg|jpeg|gif)$/i, type: "asset/resource", } ] }, resolve: { alias: { "~": path.resolve("./"), }, }, plugins: [ new CopyPlugin({ patterns: [ { from: path.resolve("./assets/images"), to: path.resolve("./wwwroot/images"), } ], }) ] }; module.exports = (env, argv) => { if (argv.mode === "development") { // Development specific configuration. config.devtool = "eval-source-map"; } if (argv.mode === "production") { // Production specific configuration. config.devtool = "nosources-source-map"; } return config; };