Skip to content

Commit

Permalink
fix(webpack): ensure NODE_ENV is defaulted to development for dev-ser…
Browse files Browse the repository at this point in the history
…ver, and HMR works
  • Loading branch information
jaysoo committed Feb 10, 2023
1 parent 47a4ff4 commit dcd4d50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/webpack/src/executors/dev-server/dev-server.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export async function* devServerExecutor(
serveOptions: WebDevServerOptions,
context: ExecutorContext
) {
// Default to dev mode so builds are faster and HMR mode works better.
process.env.NODE_ENV ??= 'development';

const { root: projectRoot, sourceRoot } =
context.projectsConfigurations.projects[context.projectName];
const buildOptions = normalizeOptions(
Expand Down
11 changes: 10 additions & 1 deletion packages/webpack/src/plugins/write-index-html-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,17 @@ export class WriteIndexHtmlPlugin {
name: string;
extension: string;
}[] = [];

// This test excludes files generated by HMR (e.g. main.hot-update.js).
const jsAssetRegExp = /(?<!hot-update).js$/;

for (const { file, name, extension, initial } of files) {
if (name && initial && extensionFilter.includes(extension)) {
if (
name &&
initial &&
extensionFilter.includes(extension) &&
jsAssetRegExp.test(file)
) {
filteredFiles.push({ file, extension, name });
}
}
Expand Down

0 comments on commit dcd4d50

Please sign in to comment.