fix(web): set envName to production when script optimization is enabled (#5522)
ISSUES CLOSED: #5512
This commit is contained in:
parent
9258ef3816
commit
cd3dd9431a
@ -442,16 +442,18 @@ describe('getBaseWebpackPartial', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should support envName overrides', () => {
|
||||
it('should set envName to production when script optimization is enabled', () => {
|
||||
const esm = true;
|
||||
const isScriptOptimizeOn = true;
|
||||
const emitDecoratorMetadata = true;
|
||||
const result = getBaseWebpackPartial(
|
||||
{
|
||||
...input,
|
||||
progress: true,
|
||||
},
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'production'
|
||||
esm,
|
||||
isScriptOptimizeOn,
|
||||
emitDecoratorMetadata
|
||||
);
|
||||
|
||||
const rule = result.module.rules.find(
|
||||
@ -464,5 +466,31 @@ describe('getBaseWebpackPartial', () => {
|
||||
babelrc: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('should override envName when script optimization is disabled', () => {
|
||||
const esm = true;
|
||||
const isScriptOptimizeOn = false;
|
||||
const emitDecoratorMetadata = true;
|
||||
const result = getBaseWebpackPartial(
|
||||
{
|
||||
...input,
|
||||
progress: true,
|
||||
},
|
||||
esm,
|
||||
isScriptOptimizeOn,
|
||||
emitDecoratorMetadata,
|
||||
'staging'
|
||||
);
|
||||
|
||||
const rule = result.module.rules.find(
|
||||
(r) => typeof r.loader === 'string' && r.loader.match(/babel-loader/)
|
||||
);
|
||||
expect(rule.options).toMatchObject({
|
||||
rootMode: 'upward',
|
||||
cwd: '/root/root/src',
|
||||
envName: 'staging',
|
||||
babelrc: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -57,7 +57,7 @@ export function getBaseWebpackPartial(
|
||||
cwd: join(options.root, options.sourceRoot),
|
||||
emitDecoratorMetadata,
|
||||
isModern: esm,
|
||||
envName: configuration,
|
||||
envName: isScriptOptimizeOn ? 'production' : configuration,
|
||||
babelrc: true,
|
||||
cacheDirectory: true,
|
||||
cacheCompression: false,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user