-
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
feat(build): add support for webpack stats JSON output #4189
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
82b1eac
to
a5c18ad
Compare
Writing to stdout would be useful for automation purposes. other output would need to be disabled though. If not, then being able to specify the output file would also be useful. |
@clydin I'm ok with that. I could add something like this:
I'll let @filipesilva @hansl decide if that is something they want to support. |
a5c18ad
to
c476f9f
Compare
packages/angular-cli/tasks/build.ts
Outdated
const jsonStats = stats.toJson('verbose'); | ||
|
||
fs.writeFileSync( | ||
path.resolve(project.root, outputDir, 'stats.json'), |
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.
@winkerVSbecks I think outputDir
should be outputPath
. There is no variable outputDir
. That's what the compiler complains about and why the tests fail in ci.
d1df040
to
7a55eb7
Compare
dbf5f2a
to
c97a0db
Compare
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.
Can you also add this flag to https://github.com/angular/angular-cli/blob/master/docs/documentation/build.md?
]; | ||
|
||
export interface BuildTaskOptions extends BuildOptions { | ||
watch?: boolean; | ||
watcher?: string; | ||
supressSizes: boolean; |
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.
Can you remove these changes? They're redundant and should be obtained from BuildOptions
.
c97a0db
to
3b07927
Compare
@filipesilva done |
@winkerVSbecks I don't see the changes in, the interface still has all the duplicated members. |
]; | ||
|
||
export interface BuildTaskOptions extends BuildOptions { | ||
watch?: boolean; | ||
baseHref?: string; |
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.
This should be only
export interface BuildTaskOptions extends BuildOptions {
watch?: boolean;
statsJson?: boolean;
}
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.
sorry, I misunderstood that.
docs/documentation/build.md
Outdated
@@ -94,3 +94,5 @@ or `ng serve --prod` will also make use of uglifying and tree-shaking functional | |||
`--extract-css` (`-ec`) extract css from global styles onto css files instead of js ones | |||
|
|||
`--output-hashing` define the output filename cache-busting hashing mode | |||
|
|||
`--json` generates a `stats.json` file which can be analyzed using tools such as: `webpack-bundle-analyzer` or https://webpack.github.io/analyse |
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.
Can you change this to --stats-json
?
3b07927
to
c4fca3d
Compare
@@ -31,10 +31,12 @@ export const baseBuildCommandOptions: any = [ | |||
description: 'define the output filename cache-busting hashing mode', | |||
aliases: ['oh'] | |||
}, | |||
{ name: 'statsJson', type: Boolean, default: false }, |
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.
The weird CI errors are due to this:
kamik@T460p MINGW64 /d/sandbox/master-project (master)
$ ng build
The "statsJson" option's name of the "build" command contains a capital letter.
Error: The "statsJson" option's name of the "build" command contains a capital letter.
at Class.Command.validateOption (D:\work\angular-cli\packages\@angular\cli\ember-cli\lib\models\command.js:238:11)
If you change it to stats-json
it should be fine.
c4fca3d
to
71bc1ac
Compare
Thanks for implementing this and going through all the change requests! |
Allows you to run ng build --json which generates dist/stats.json. This can then be used with things like the webpack-bundle-analyzer or https://webpack.github.io/analyse/ Fix angular#3179
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. |
related to #3179
Allows you to run
ng build --json
which generatesdist/stats.json
. This can then be used with things like thewebpack-bundle-analyzer
or https://webpack.github.io/analyse/