Uh oh!
There was an error while loading. Please reload this page.
fix(build): Use static files for styles - #2646
Conversation
googlebot
commented
Oct 11, 2016
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. |
googlebot
commented
Oct 11, 2016
CLAs look good, thanks! |
filipesilva
commented
Oct 14, 2016
@TheLarkInn can you review? |
filipesilva
commented
Oct 17, 2016
@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. |
jimitndiaye
commented
Oct 18, 2016
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. |
clydin
commented
Oct 19, 2016
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 |
filipesilva
commented
Oct 23, 2016
I marked it for a merge, unless you have more changes you want to do. |
jimitndiaye
commented
Oct 23, 2016
No if we're ok with importing the no-op file then i think it's all good |
jimitndiaye
commented
Oct 23, 2016
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 |
filipesilva
commented
Oct 23, 2016
That's a possibility, but would prefer it to be in a separate PR so that it could be evaluated separately as a workaround. |
jimitndiaye
commented
Oct 23, 2016
Sure. I'll get on that once this one is merged |
clydin
commented
Oct 25, 2016
via email
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.
filipesilva
commented
Nov 2, 2016
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.
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.
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