UNPKG

@dr.pogodin/react-utils

Version:

Collection of generic ReactJS components and utils

43 lines (42 loc) 2 kB
"use strict"; // Production Webpack config for ReactJS libraries. var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = configFactory; /* eslint-disable import/no-extraneous-dependencies */ const node_path_1 = __importDefault(require("node:path")); const css_minimizer_webpack_plugin_1 = __importDefault(require("css-minimizer-webpack-plugin")); const webpack_1 = __importDefault(require("webpack")); const webpack_merge_1 = require("webpack-merge"); const lib_base_1 = __importDefault(require("./lib-base")); function configFactory(ops) { const { outputPath = 'build/production' } = ops; const baseConfig = (0, lib_base_1.default)(Object.assign(Object.assign({}, ops), { babelEnv: 'production', cssLocalIdent: '[hash:base64:6]', mode: 'production', outputPath: node_path_1.default.resolve(__dirname, ops.context, outputPath) })); return (0, webpack_merge_1.merge)(baseConfig, { devtool: 'source-map', optimization: { minimizer: [ '...', new css_minimizer_webpack_plugin_1.default({ minimizerOptions: { preset: ['default', { /* Due to the way our styles are organized, these dangerous * optimizations can break our styles, thus they are disabled. */ discardUnused: false, reduceIdents: false, zindex: false, }], }, }), ], }, plugins: [ new webpack_1.default.DefinePlugin({ 'process.env.BABEL_ENV': JSON.stringify('production'), 'process.env.NODE_ENV': JSON.stringify('production'), }), ], }); }