Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

feat: use css2json loader by default #1076

Merged
merged 6 commits into from
Oct 25, 2019
Merged

feat: use css2json loader by default #1076

merged 6 commits into from
Oct 25, 2019

Conversation

vakrilov
Copy link
Contributor

@vakrilov vakrilov commented Oct 23, 2019

PR Checklist

What is the current behavior?

Css files are loaded with css-loader

What is the new behavior?

Use the css2json that does parsing the CSS files and puts parsed CSS AST (as json) in the bundle.

@cla-bot cla-bot bot added the cla: yes label Oct 23, 2019
@vakrilov vakrilov changed the base branch from master to release October 23, 2019 10:46
@vakrilov vakrilov marked this pull request as ready for review October 24, 2019 09:45
@rosen-vladimirov
Copy link
Contributor

Merging with red tests - the failure is not caused by this PR - its just flaky test.

@rosen-vladimirov rosen-vladimirov merged commit c07b8b8 into release Oct 25, 2019
@rosen-vladimirov rosen-vladimirov deleted the css2json branch October 25, 2019 18:37
@farfromrefug
Copy link

@vakrilov can you explain a little bit why it is better? Is it faster to load? Did you compare the size?

@vakrilov
Copy link
Contributor Author

vakrilov commented Nov 1, 2019

The size of the bundle is bigger. Don't have the exact measurements - but parsed JSON is bigger than it's CSS equivalent. Run-time performance is much better though - on slower devices we have observed performance increase from 1.2s to 50ms (this is theme parsing only).

The new @nativescript/theme has much more CSS and this is what made this optimization more necessary.

@farfromrefug
Copy link

@vakrilov ok got it. Dont use @nativescript/theme myself (too big). I will try and run some tests on this. Why did you disable it for non app.css on vue? Wondering if it could be good to put all in app.css then. What about imported from app.css, are they included in the json file?

THanks again for your answer, and your amazing work !

@vakrilov
Copy link
Contributor Author

vakrilov commented Nov 1, 2019

Vue and Angular have their own way of handling component-level CSS. They process the CSS additionally to add component scope (usually implemented by adding attribute selectors). Passing pre-compiled CSS to JSON will not work in that case.

In any case - the component level CSSis usually not that big and run-time parsing is good enough in that case. You will have perf problems if you import the whole theme in a component, but that is not recommended.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants