Rev 5206 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
const path = require("path");
const isDevelopment = process.env.NODE_ENV === "development";
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const TerserPlugin = require("terser-webpack-plugin");
// Add paths while bundling
const paths = {
menu: {
entry: "./react-webpack/menu/index.js",
output: path.join(__dirname, "public/react-bundles/menu"),
filename: "menuBundle.js",
}
};
// change active path here
const currentPath = paths.menu;
module.exports = {
entry: currentPath.entry,
output: {
path: currentPath.output,
filename: currentPath.filename,
},
watch: isDevelopment ? true : false,
mode: isDevelopment ? "development" : "production",
resolve: {
extensions: [".js", ".jsx", ".scss"],
},
module: {
rules: [
{
test: /(js|jsx)$/,
use: ["babel-loader"],
exclude: /node_modules/,
},
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test: /\.module\.s(a|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
modules: {
localIdentName: "[local]--[hash:base64:5]",
},
sourceMap: isDevelopment,
},
},
{
loader: "sass-loader",
options: {
sourceMap: isDevelopment,
},
},
],
},
{
test: /\.s(a|c)ss$/,
exclude: /\.module.(s(a|c)ss)$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
{
loader: "sass-loader",
options: {
sourceMap: isDevelopment,
},
},
],
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css",
}),
],
optimization: {
minimizer: [
new TerserPlugin({
extractComments: false,
}),
],
},
};