79 lines
2.2 KiB
JavaScript
79 lines
2.2 KiB
JavaScript
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/site.js"),
|
|
path.resolve("./assets/js/dependencies.js"),
|
|
path.resolve("./assets/styles/site.scss"),
|
|
path.resolve("./assets/styles/dependencies.css")
|
|
],
|
|
}
|
|
),
|
|
output: {
|
|
filename: "[name].js",
|
|
path: path.resolve("./wwwroot/js"),
|
|
clean: true,
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.m?js$/,
|
|
exclude: /(node_modules|bower_components)/,
|
|
use: {
|
|
loader: "babel-loader",
|
|
options: {
|
|
presets: ["@babel/preset-env"],
|
|
plugins: ["@babel/plugin-transform-runtime"]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
test: /\.s[ac]ss$/i,
|
|
use: [
|
|
"style-loader",
|
|
"css-loader",
|
|
"sass-loader",
|
|
],
|
|
},
|
|
{
|
|
test: /\.css$/i,
|
|
use: ["style-loader", "css-loader"],
|
|
},
|
|
{
|
|
test: /\.(png|svg|jpg|jpeg|gif)$/i,
|
|
type: "asset/resource",
|
|
},
|
|
{
|
|
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
type: "asset/resource",
|
|
},
|
|
]
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
"~": path.resolve("./"),
|
|
},
|
|
},
|
|
plugins: [
|
|
new CopyPlugin({
|
|
patterns: [
|
|
{
|
|
from: path.resolve("./assets/images"), to: path.resolve("./wwwroot/images"),
|
|
}
|
|
],
|
|
})
|
|
]
|
|
};
|
|
|
|
module.exports = config;
|