When building an Angular 2 app using Angular CLI/webpack, I'd like to specify values for a few Sass variables. Like make some url(#{$my-base-path}/...)
or $fa-font-path
point to a CDN in production, or simply set different background colors for acceptance and production builds.
I like how Angular CLI picks a config from, e.g., environments/environment.prod.ts
. But I'd also happily use additional command line parameters for ng build
, but no luck so far:
Without Angular CLI, I guess I could use Sass custom functions on the command line, but I don't know how I could use that approach along with Angular CLI.
Maybe I can specify the path to some specific
my-variables.sccs
to use for all Sass compilations?Webpack's sass-loader states the following, but I've no clue if I can use that with Angular CLI:
Environment variables
If you want to prepend Sass code before the actual entry file, you can simply set the
data
option. In this case, the sass-loader will not override thedata
option but just append the entry's content. This is especially useful when some of your Sass variables depend on the environment:{ loader: "sass-loader", options: { data: "$env: " + process.env.NODE_ENV + ";" } }
Any idea?