@ngtools/webpack Conflict between DefinePlugin and AngularCompilerPlugin
Variables defined by the Webpack DefinePlugin are not available to the config object of the RouterModule.
Versions
@angular/compiler: 5.1.2
@angular/compiler-cli: 5.1.2
Repro steps
// webpack config
new DefinePlugin({
PRODUCTION: Boolean(env.production)
}),
// app module
const router = RouterModule.forRoot([...], {
enableTracing: !PRODUCTION
});
@NgModule({
imports: [
router
]
})
export class AppModule {
}
Observed behavior
The value of PRODUCTION as defined by the DefinePlugin is not used and enableTracing is always true.
Desired behavior
I should be able to configure the RouterModule using variables defined by the DefinePlugin.
Mention any other details that might be useful (optional)
The following test.zip file contains a minimal project to reproduce the issue. Download the zip file then run
npm install
npm start
Open a browser to localhost:3000 and notice that the router events are always logged to the console regardless of the value of PRODUCTION as defined in the webpack.config.js file.
how about using env.production instead?
imported from environment.ts
more here https://github.com/angular/angular-cli/wiki/stories-application-environments
I’m not using the Angular CLI. Will the AngularCompiler Wepack plugin look for an .angular-cli.json file?
The environment file approach won’t allow for code elimination when minified, unlike the DefinePlugin.
This only happens when ENV variables are used in decorators' metadata.
Duplicate of #9051.
Duplicate of #9051.
Duplicates itself?
Apologies, should be duplicate of #9874. Must have copy-pasted from the wrong tab.
Subscribe. I pass env variables in my webpack to server and Angular AOT client. Everything is fine on server, but client env are empty {}.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.