@dr.pogodin/react-utils
Version:
Collection of generic ReactJS components and utils
56 lines (55 loc) • 2.56 kB
JavaScript
;
/**
* @category Configs
* @module webpack/app-production
* @desc Production Webpack configuration for applications.
*/
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 css_minimizer_webpack_plugin_1 = __importDefault(require("css-minimizer-webpack-plugin"));
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
const webpack_1 = __importDefault(require("webpack"));
const webpack_merge_1 = require("webpack-merge");
const app_base_1 = __importDefault(require("./app-base"));
/**
* @param {object} ops
* @param {string} ops.context Base URL for resolution of relative config paths.
* @param {boolean} [ops.dontEmitBuildInfo] If set the `.build-info` file won't
* be created at the disk during the compilation.
*/
function configFactory(ops) {
const entry = [
'@dr.pogodin/react-utils/build/production/client/init',
...Array.isArray(ops.entry) ? ops.entry : [ops.entry],
];
const res = (0, webpack_merge_1.merge)((0, app_base_1.default)(Object.assign(Object.assign({ babelLoaderExclude: [] }, ops), { babelEnv: 'production', babelLoaderOptions: Object.assign({ compact: true }, ops.babelLoaderOptions), entry, mode: 'production' })), {
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'),
}),
new mini_css_extract_plugin_1.default(Object.assign({ chunkFilename: '[contenthash].css', filename: '[contenthash].css' }, ops.cssExtractionOptions)),
],
});
return res;
}