angular-cli comes with out-of-box environments. if you have already selected a project using ng eject , you will need to manually configure the environment files
you can pass environment variables to the webpack assembly for whatever values ββyou want. I use the env variable for transmission in the environment and select the environment configuration file, but you can set other variables as shown below.
My package.json provides an environment flag during the script build process
"scripts": { "ng": "ng", "start": "webpack-dev-server --env.target=local --port=4200 --history-api-fallback", "build:prod": "webpack --env.target=prod --env.zip --env.aot --env.extreme --colors",
You can use the environment flag
// export a function that returns a promise that returns the config object module.exports = function(env) { const isAot = env.aot || false; const isZip = env.zip || false; const isExtreme = env.extreme || false; const isAnalyze = env.analyze || false; const isVirtualbox = env.virtualbox || false; const isLocal = env.target === 'local'; if(isLocal) { /* set the css file to a variable mycssfile*/ }
source share