53 lines
2.2 KiB
JavaScript
53 lines
2.2 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.setOptimizationRules = void 0;
|
|
const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
|
|
/**
|
|
* Установка правил оптимизации сборки.
|
|
*/
|
|
const setOptimizationRules = (options) => (Object.assign({ minimize: true, minimizer: [new terser_webpack_plugin_1.default()], runtimeChunk: false, splitChunks: {
|
|
minSize: 17000,
|
|
minRemainingSize: 0,
|
|
minChunks: 1,
|
|
maxAsyncRequests: 30,
|
|
automaticNameDelimiter: '_',
|
|
maxInitialRequests: 30,
|
|
enforceSizeThreshold: 30000,
|
|
cacheGroups: {
|
|
vendors: {
|
|
test: /[/\\]node_modules[/\\]/,
|
|
name: (module) => {
|
|
const { name } = module.resourceResolveData.descriptionFileData;
|
|
return name === null || name === void 0 ? void 0 : name.replace('@', '').replace('/', '_');
|
|
},
|
|
minSize: 0,
|
|
priority: -10,
|
|
reuseExistingChunk: true,
|
|
},
|
|
default: {
|
|
minChunks: 2,
|
|
priority: -20,
|
|
reuseExistingChunk: true,
|
|
},
|
|
fractalPackages: {
|
|
test: /[/\\]node_modules[/\\](@fractal-ui)\//,
|
|
reuseExistingChunk: true,
|
|
name: (module) => {
|
|
const { name } = module.resourceResolveData.descriptionFileData;
|
|
return name === null || name === void 0 ? void 0 : name.replace('@', '').replace('/', '_');
|
|
},
|
|
priority: 10,
|
|
},
|
|
reactPackages: {
|
|
test: /[/\\]node_modules[/\\](react|react-dom|react-router-dom|react-animate-height|react-dnd|react-dnd-html5-backend)\//,
|
|
reuseExistingChunk: true,
|
|
name: (module) => module.resourceResolveData.descriptionFileData.name,
|
|
priority: 20,
|
|
},
|
|
},
|
|
} }, options));
|
|
exports.setOptimizationRules = setOptimizationRules;
|