Skip to content

Compile component styles into styles.bundle.css #7219

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

Closed
MickL opened this issue Jul 31, 2017 · 6 comments
Closed

Compile component styles into styles.bundle.css #7219

MickL opened this issue Jul 31, 2017 · 6 comments

Comments

@MickL
Copy link

MickL commented Jul 31, 2017

Bug Report or Feature Request (mark with an x)

- [ ] bug report
- [X] feature request

Versions.

v1.3.0-rc.3

Repro steps.

Compile (ng start / build) with --extract-css true. Styles set in .angular-cli.json will be bundled into a single file (correct). Component styles are still inline (and, btw, have no sourcemaps).

Further question

Is it possible to concat component-styles with the main style.bundle.css to have a single css-file only? If this is done before sass runs, this would also solve #1253

@filipesilva
Copy link
Contributor

This is actually by design. Component styles are isolated and get special handling by the AOT compiler. So in that sense there is no point to try and put it in the global styles.

#1253 is solved by importing the css variables into the component css. It might be tedious, but it is correct since they are isolated. If you don't care about the isolation you can turn view encapsulation off and just use global styles anyway.

@ghost
Copy link

ghost commented Mar 14, 2018

Since inline styles are violating CSP, then Angular 2 becomes unusable in environments that require the use of restrictive CSP

@stich6269
Copy link

Google page speed checker is mark inline styles like a uncompressed tex, and gives a strike(

@psmyrdek
Copy link

Imagine such case:

  1. I'm building a dynamic app using Angular - all the styles sit next to components
  2. I want to use the same styles on the landing page where .js is not needed, and I want to server-render "component-like" html to show users what's waiting for them after signing in
  3. Without the possibility to extract component styles... all of that is not possible

That's really, really bad idea.

@MickL
Copy link
Author

MickL commented Jan 26, 2019

You dont have to use component styles. Component styles are lazy loaded with the corresponding module and applied using shadow dom (emulation). They have tons of benefits but are not made for usage outside at all. But you can write your global styles they are great for overall styling and also import your global variables and mixins into component styles.

I think it is correct that this issue is closed.

@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 9, 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

4 participants