Open Nick-Lucas opened 6 months ago
Currently the rspack plugin seems not to support
process
out of the box, so the normal configuration approach of .env files in Nx does not work.
https://www.rspack.dev/guide/language-support.html#node-polyfills
I stumled upon the same problem. The env files are read properly, but the define plugin is missing.
My workaround (the code must be added in the rspack.config file):
const defines = {}
Object.keys(process.env).forEach(function(key) {
if(key.startsWith("NX_")) {
defines['process.env.' + key] = JSON.stringify(process.env[key])
}
});
config.plugins.push(new rspack.DefinePlugin(defines))
This will replace all process.env.NX_* variables in the frontend code.
Currently the rspack plugin seems not to support
process
out of the box, so the normal configuration approach of .env files in Nx does not work.