-
Notifications
You must be signed in to change notification settings - Fork 12k
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
fix(build): Use static files for styles #2646
Conversation
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
CLAs look good, thanks! |
@TheLarkInn can you review? |
@jimitndiaye had a look with @TheLarkInn, it looks good but for this sort of enhancement we do need some tests. The ones in https://github.com/angular/angular-cli/tree/master/tests/e2e/tests/build/styles can already validate that the dev build works as before, but we need to know that the prod builds work as intended. Getting the styles file with hash is kinda hard since the hash is random, my suggestion is to both check Prod tests for css/sass/less would be ideal. |
@filipesilva Sure, I'll add a check in https://github.com/angular/angular-cli/blob/master/tests/e2e/tests/build/prod-build.ts#L36 to check for the existence of the hashed styles file in index.html. |
Ended up modifying https://github.com/angular/angular-cli/blob/master/tests/e2e/tests/build/styles/css.ts to include additional assertions for the prod build, since it was the only test case that dealt with the styles bundle. |
Development builds continue to use style-loader for fast developer workflow (HMR). Production builds use static, minimized, CSS file.
…in style bundle file name
e2e tests now include
|
@filipesilva The extract-text-plugin removes all the css from styles.bundle.js and puts in styles.bundle.css, leaving the javascript file largely empty (just no-op functions remain). This JS file is till being included in index.html, even though it doesn't really serve a useful purpose any more. What do you think about excluding it from the HtmlWebpackPlugin. At the moment it is just an extra HTTP request that serves no useful purpose. Just a few bytes but still unnecessary. |
There is an open webpack issue regarding the no-op file: webpack/webpack#1967 |
Thanks for adding the tests @jimitndiaye, they look good! You're right that the Regarding the no-op file, did you test removing it via |
I marked it for a merge, unless you have more changes you want to do. |
No if we're ok with importing the no-op file then i think it's all good |
There's the option of including the global styles in the main entry though. This would mean styles.bundle.js would not be created and styles.bundle.css would be extracted from the main entry |
That's a possibility, but would prefer it to be in a separate PR so that it could be evaluated separately as a workaround. |
Sure. I'll get on that once this one is merged |
With the lack of movement on the web pack issue that might be a better option. Although, personally I like the separation; seems cleaner.
|
PR angular#2646 introduced new e2e tests that give positive feedback without running all tests.
Thanks for the great on this @jimitndiaye! |
|
||
.then(() => ng('build', '--prod')) | ||
.then(() => new Promise<string>(() => | ||
glob.sync('dist/styles.*.bundle.css').find(file => !!file))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You never resolve this promise, causing tests to stop early. This test is causing our e2e to not continue.
Also, no need to return a promise, just return the glob.sync
.
Fix angular#2148 Fix angular#2020 Fix angular#2826 Close angular#2646
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Uses extract-loader to prepare static files for styles rather than use style-loader and thus avoids FOUC.
Fix #2148
Fix #2020
Fix #2826