guild_front/config/webpack/prod.js
2023-05-24 15:34:43 +03:00

60 lines
1.3 KiB
JavaScript

const paths = require("../paths");
const { merge } = require("webpack-merge");
const common = require("./common");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = merge(common, {
mode: "production",
target: "browserslist",
entry: {
index: {
import: `${paths.src}/index.js`,
dependOn: ["react", "helpers"],
},
react: ["react", "react-dom", "prop-types"],
helpers: ["immer", "nanoid"],
},
devtool: false,
output: {
filename: "js/[name].[hash:8].bundle.js",
publicPath: "/",
assetModuleFilename: "[hash][ext][query]",
},
module: {
rules: [
{
test: /\.(c|sa|sc)ss$/i,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: { importLoaders: 1 },
},
"postcss-loader",
"sass-loader",
],
},
{
test: /\.(jpe?g|png|gif|svg|webp)$/i,
type: "asset/resource",
// type: 'asset'
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
chunkFilename: "[id].css",
}),
],
optimization: {
runtimeChunk: "single",
},
performance: {
hints: "warning",
maxEntrypointSize: 512000,
maxAssetSize: 512000,
},
});