chore(build) rename option for clarity

This commit is contained in:
Saúl Ibarra Corretgé 2022-09-19 15:13:42 +02:00 committed by Saúl Ibarra Corretgé
parent 1703ed8b23
commit e18240cfc6
1 changed files with 12 additions and 12 deletions

View File

@ -20,15 +20,15 @@ const devServerProxyTarget
* *
* @param {Object} options - options for the bundles configuration. * @param {Object} options - options for the bundles configuration.
* @param {boolean} options.analyzeBundle - whether the bundle needs to be analyzed for size. * @param {boolean} options.analyzeBundle - whether the bundle needs to be analyzed for size.
* @param {boolean} options.minimize - whether the code should be minimized or not. * @param {boolean} options.isProduction - whether this is a production build or not.
* @param {number} size - the size limit to apply. * @param {number} size - the size limit to apply.
* @returns {Object} a performance hints object. * @returns {Object} a performance hints object.
*/ */
function getPerformanceHints(options, size) { function getPerformanceHints(options, size) {
const { analyzeBundle, minimize } = options; const { analyzeBundle, isProduction } = options;
return { return {
hints: minimize && !analyzeBundle ? 'error' : false, hints: isProduction && !analyzeBundle ? 'error' : false,
maxAssetSize: size, maxAssetSize: size,
maxEntrypointSize: size maxEntrypointSize: size
}; };
@ -90,15 +90,15 @@ function devServerProxyBypass({ path }) {
* *
* @param {Object} options - options for the bundles configuration. * @param {Object} options - options for the bundles configuration.
* @param {boolean} options.detectCircularDeps - whether to detect circular dependencies or not. * @param {boolean} options.detectCircularDeps - whether to detect circular dependencies or not.
* @param {boolean} options.minimize - whether the code should be minimized or not. * @param {boolean} options.isProduction - whether this is a production build or not.
* @returns {Object} the base config object. * @returns {Object} the base config object.
*/ */
function getConfig(options = {}) { function getConfig(options = {}) {
const { detectCircularDeps, minimize } = options; const { detectCircularDeps, isProduction } = options;
return { return {
devtool: minimize ? 'source-map' : 'eval-source-map', devtool: isProduction ? 'source-map' : 'eval-source-map',
mode: minimize ? 'production' : 'development', mode: isProduction ? 'production' : 'development',
module: { module: {
rules: [ { rules: [ {
// Transpile ES2015 (aka ES6) to ES5. Accept the JSX syntax by React // Transpile ES2015 (aka ES6) to ES5. Accept the JSX syntax by React
@ -186,11 +186,11 @@ function getConfig(options = {}) {
__filename: true __filename: true
}, },
optimization: { optimization: {
concatenateModules: minimize, concatenateModules: isProduction,
minimize minimize: isProduction
}, },
output: { output: {
filename: `[name]${minimize ? '.min' : ''}.js`, filename: `[name]${isProduction ? '.min' : ''}.js`,
path: `${__dirname}/build`, path: `${__dirname}/build`,
publicPath: '/libs/', publicPath: '/libs/',
sourceMapFilename: '[file].map' sourceMapFilename: '[file].map'
@ -274,12 +274,12 @@ module.exports = (_env, argv) => {
const isProduction = mode === 'production'; const isProduction = mode === 'production';
const configOptions = { const configOptions = {
detectCircularDeps: Boolean(process.env.DETECT_CIRCULAR_DEPS), detectCircularDeps: Boolean(process.env.DETECT_CIRCULAR_DEPS),
minimize: isProduction isProduction
}; };
const config = getConfig(configOptions); const config = getConfig(configOptions);
const perfHintOptions = { const perfHintOptions = {
analyzeBundle, analyzeBundle,
minimize: isProduction isProduction
}; };
return [ return [