Skip to content

Instantly share code, notes, and snippets.

View tristanidoux's full-sized avatar

Tristan Idoux tristanidoux

View GitHub Profile
@tristanidoux
tristanidoux / @ngtools+webpack+9.1.10.patch
Last active July 25, 2024 12:08
Enable ifdef-loader preprocessing with webpack 7+
Since @ngtools/webpack doesn't support preprocess chain loader, see (here)[https://github.com/nippur72/ifdef-loader/issues/4].
We use process.env to pass the ifdef loader options and patch the compiler (webpack) to read the env and parse the files.
We use a prefix 'IFDEF_' to filter the environment variables.
This is more a fix than anything else for now. A better fix would have been a PR to enable webpack to use any preprocessor
but I don't have the time right now.
diff --git a/node_modules/@ngtools/webpack/src/compiler_host.js b/node_modules/@ngtools/webpack/src/compiler_host.js
index 58d942c..a7db0be 100644
--- a/node_modules/@ngtools/webpack/src/compiler_host.js