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

Distribute individual component CSS in npm #4623

Closed
Ne-Ne opened this issue Dec 7, 2017 · 4 comments
Closed

Distribute individual component CSS in npm #4623

Ne-Ne opened this issue Dec 7, 2017 · 4 comments
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@Ne-Ne
Copy link

Ne-Ne commented Dec 7, 2017

Hi Prime Team,

I'm submitting a ...

[ ] bug report => Search github for a similar issue or PR before submitting
[x] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Request:
I want to reduce the bundle size of my application. At the moment I am loading the components into the app perfectly fine. However, the styles are in a massive bloated file.

I cannot see anything on the roadmap about scoping the styles using style or styleurls within the @component

What is the motivation / use case for changing the behavior?
Small files on load, scope the styles to the component in question.

Angular version:
4.3

PrimeNG version:
4.0.3

TypeScript Language:
2.4.2

Many thanks,

Neil

@Ne-Ne
Copy link
Author

Ne-Ne commented Dec 16, 2017

@cagataycivici What do you think?

@cagataycivici cagataycivici changed the title Scoping .css styles - style / styleUrls Distribute individual component CSS in npm Dec 19, 2017
@cagataycivici cagataycivici self-assigned this Dec 19, 2017
@cagataycivici cagataycivici added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Dec 19, 2017
@cagataycivici cagataycivici added this to the 5.1.0-RC1 milestone Dec 19, 2017
@cagataycivici
Copy link
Member

We'll also make the individual css of components for 5.1.0-RC! so you can import what you require as well instead of whole css. PrimeNG is a suite so no plans to use style or styleURL which always caused problems for us due to view encapsulation. Still we may reconsider that in future, having said that publishing individual css of components will help your requirement, I'll also update the docs for this in detail in a section called smaller bundles :)

@Ne-Ne
Copy link
Author

Ne-Ne commented Dec 19, 2017

Thanks for your response @cagataycivici

Our internal suite of components uses:

import { ViewEncapsulation } from "@angular/core";

Then enforced via @Component:

encapsulation: ViewEncapsulation.None.

We found that you can turn off the encapsulation for each component, there are no overriding scoping issues. The benefits we drew at work are:

  • Smaller bundle size
  • On-demand styles
  • No scoping styles issues
  • Lower specificity range - due to no [_ngcontent-??]

Is this something that we can consider doing?

Many thanks.

@cagataycivici
Copy link
Member

This is a huge change, we need to make sure backward compatibility such as premium themes and so on. First let me do add css to the distro and then test using styles or styleUrls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

2 participants