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
(cherry picked from commit c3e0602)
  • Loading branch information
jaysoo authored and FrozenPandaz committed Oct 3, 2022
1 parent 7733769 commit 2f2c7d8
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 2f2c7d8

Please sign in to comment.