Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular-cli - How to output a certain scss file to a diferent file than the bundle css #6899

Closed
humarkx opened this issue Jul 6, 2017 · 11 comments

Comments

@humarkx
Copy link

humarkx commented Jul 6, 2017

This is the case:

I have all the scss files imported into styles.scss, so when it compiles, it gives me, a bundle styles.css.

All i want is to have a styles.scss and a custom.scss that after build, it will generate a syles.css and a custom.css. Not only a bundle but 2 diferent output files.

Thanks

@Brocco Brocco added P5 The team acknowledges the request but does not plan to address it, it remains open for discussion severity2: inconvenient labels Jul 17, 2017
@filipesilva
Copy link
Contributor

Heya, have a look at https://github.com/angular/angular-cli/wiki/stories-global-styles, you can see input and output properties in the alternative configuration item. That allows you to select what the output file is.

@xmlking
Copy link

xmlking commented Jan 24, 2018

I want to produce css from scss so that I can load .css dynamically based on theme selected by user.

expected output:
dist/app/styles/themes/deeppurple-amber.css
dist/app/styles/themes/indigo-pink.css
dist/app/styles/themes/pink-bluegrey.css
dist/app/styles/themes/purple-green.css

I tryed this , but I getting .js instead of .css

      "styles": [
        "styles.scss",
        { "input": "styles/themes/deeppurple-amber.scss", "lazy": true },
        { "input": "styles/themes/indigo-pink.scss", "lazy": true },
        { "input": "styles/themes/pink-bluegrey.scss", "lazy": true },
        { "input": "styles/themes/purple-green.scss", "lazy": true }
      ],

is there a way to accomplish what I needed using angular-cli ?

@Beni90
Copy link

Beni90 commented Jan 29, 2018

@xmlking did you find a solution for this?

@xmlking
Copy link

xmlking commented Jan 30, 2018

@Beni90 not a clean solution but created an extra webpack config and using webpack --config tools/webpack.config.js command as part of build process:

Ref:
https://github.com/xmlking/nx-starter-kit/blob/master/tools/webpack.config.js

https://github.com/xmlking/nx-starter-kit/blob/master/package.json#L22

@filipesilva filipesilva removed P5 The team acknowledges the request but does not plan to address it, it remains open for discussion severity2: inconvenient labels Feb 14, 2018
@hgopi
Copy link

hgopi commented Feb 26, 2018

@xmlking You could use ng build --extract-css to output the styles to css files.

@xmlking
Copy link

xmlking commented Feb 26, 2018

thanks @hgopi . I solved this with following setup

.angular-cli.json

      "styles": [
        "styles.scss",
        {
          "input": "styles/themes/deeppurple-amber.scss",
          "output": "assets/themes/deeppurple-amber",
          "lazy": true
        },
        {
          "input": "styles/themes/indigo-pink.scss",
          "output": "assets/themes/indigo-pink",
          "lazy": true
        },
        {
          "input": "styles/themes/pink-bluegrey.scss",
          "output": "assets/themes/pink-bluegrey",
          "lazy": true
        },
        {
          "input": "styles/themes/purple-green.scss",
          "output": "assets/themes/purple-green",
          "lazy": true
        }
      ],

dev serve

ng s -e mock --extract-css --preserve-symlinks -o

prod build

ng build --prod -oh=media

@FirstVertex
Copy link

It is broken on Angular CLI 6.1.0. I receive message like:

Schema validation failed with the following errors:
  Data path ".styles[1]" should NOT have additional properties(output).
  Data path ".styles[1]" should be string.
  Data path ".styles[1]" should match exactly one schema in oneOf.

CLI 6.1.0 not support complex value in "styles" only array of string.

@clydin
Copy link
Member

clydin commented Aug 3, 2018

@hughanderson4 It supports the longhand form. From reviewing the schema, output should be bundleName though.

@FirstVertex
Copy link

@clydin thanks. Can you please provide a link to this schema?

@abney317
Copy link

abney317 commented Aug 7, 2018

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants