angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Ability to specify different styling per environment

Open jstoppa opened this issue 9 years ago • 25 comments

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [X] feature request

Versions.

@angular/cli: 1.0.0 node: 6.9.1 os: win32 x64

Desired functionality.

Ability to specify different styling per environment

Mention any other details that might be useful.

I’d like to have the ability to pass the styling when executing ng serve or ng build in the same way the environment parameter works (or… is it a way to do this already with angular cli?) We need this because we are building a product that will have different styling per client

Example: At the moment, the angular-cli.json takes styling like in the example below (adding the environment configuration to put more context to the desired functionality):

"styles": [
 	"styles.scss"
 ],
"environment": "environments/environment.ts",
"environmentSource": "environments/environment.ts",
"environments": {
	"development ": "environments/development/environment.ts",
	"client1": "environments/client1/environment.ts",
	"client2": "environments/client1/environment.ts"
}

I would ideally like to be able to set a different style list per environment, I’m suggesting something like this:

"styles": {
 	"development": [
 		"environments/development/styles/styles.scss"		
 	],
 	"client1": [
 		"environments/client1/styles/styles.scss"		
 	],
 	"client2": [
		"environments/client2/styles/styles.scss"
 	]
 }
"environment" : "environments/environment.ts",
"environmentSource": "environments/environment.ts",
"environments": {
	"development ": "environments/development/environment.ts",
	"client1": "environments/client1/environment.ts",
	"client2": "environments/client1/environment.ts"
}

Then I would run: for development: ng serve --environemnt:development --style:development ng build --bh /development/ --environemnt:development --style:development

for client1: ng serve --environemnt:client1 --style:client1 ng build --bh /client1/ --environemnt:client1 --style:client1

for client2: ng serve --environemnt:client2 --style:client2 ng build --bh /client2/ --environemnt:client2 --style:client2

jstoppa avatar Apr 03 '17 09:04 jstoppa

It would be nice to have this functionality. we got this working using a very convoluted way by running a bash script before the build runs which changes the style.scss programmatically to point the imports to the right environment. Not ideal but works.

jstoppa avatar Jan 15 '19 08:01 jstoppa

Can't you already achieve this functionality with fileReplacements? I haven't tried this, but it seems logical that you could simply do something like the following:

"configurations": {
  "production": {
    "fileReplacements": [
      {
        "replace": "src/environments/development/styles.scss",
        "with": "src/environments/client1/styles.scss"
      }
    ]
  }
}

skreborn avatar Jan 15 '19 08:01 skreborn

good point! I wasn’t aware of this, I’ll give it a try Thanks!!! On Tue, 15 Jan 2019 at 08:27, Levente Morva [email protected] wrote:

Can't you already achieve this functionality with fileReplacements https://angular.io/guide/build#configure-target-specific-file-replacements? I haven't tried this, but it seems logical that you could simply do something like the following:

"configurations": { "production": { "fileReplacements": [ { "replace": "src/environments/development/styles.scss", "with": "src/environments/client1/styles.scss" } ], ...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/5803#issuecomment-454305965, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBj-wuuWmkoywese-IAp9t5q5S-IC2Xks5vDZDcgaJpZM4MxS6Q .

jstoppa avatar Jan 15 '19 08:01 jstoppa

You can can do this today using the --configuration option to override any part of the build options. Please see https://angular.io/guide/workspace-config#alternate-build-configurations for more information.

filipesilva avatar Oct 01 '19 15:10 filipesilva

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.