Skip to content

Commit

Permalink
fix(bundling): set NODE_ENV correctly to avoid warnings (#12331)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Sep 30, 2022
1 parent a14646a commit c3e0602
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions e2e/webpack/src/webpack.test.ts
Expand Up @@ -27,6 +27,8 @@ describe('Webpack Plugin', () => {
runCLI(`build ${myPkg}`);
let output = runCommand(`node dist/libs/${myPkg}/main.js`);
expect(output).toMatch(/Hello/);
expect(output).not.toMatch(/Conflicting/);
expect(output).not.toMatch(/process.env.NODE_ENV/);

updateProjectConfig(myPkg, (config) => {
delete config.targets.build;
Expand Down
2 changes: 2 additions & 0 deletions packages/webpack/src/utils/config.ts
Expand Up @@ -189,6 +189,8 @@ export function getBaseWebpackPartial(
runtimeChunk: true,
};
}
webpackConfig.optimization ??= {};
webpackConfig.optimization.nodeEnv = process.env.NODE_ENV ?? mode;
}

const extraPlugins: WebpackPluginInstance[] = [];
Expand Down
2 changes: 0 additions & 2 deletions packages/webpack/src/utils/webpack/partials/common.ts
Expand Up @@ -193,8 +193,6 @@ export function getCommonConfig(
} catch {}

return {
mode:
scriptsOptimization || stylesOptimization ? 'production' : 'development',
profile: buildOptions.statsJson,
resolve: {
extensions: ['.ts', '.tsx', '.mjs', '.js'],
Expand Down

0 comments on commit c3e0602

Please sign in to comment.