Skip to content

Feature: Tidy up the generated production build #3717

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

Closed
Perezmarc opened this issue Dec 23, 2016 · 8 comments
Closed

Feature: Tidy up the generated production build #3717

Perezmarc opened this issue Dec 23, 2016 · 8 comments

Comments

@Perezmarc
Copy link

Hi,
I get too many files that I believe are unnecessary (but maybe they're not). Would be nice to have all the production deployment options such as: How to deploy gzipped version, how to deploy not gzipped version, with sourcemaps, without sourcemaps...

This are all the files I get when I execute that command. Would appreciate a way to tidy up the production build, maybe include folders to separate files, such as 'js' & 'css'. I also would like to know if I can upload to my cloudfront the .gz without uploading the .js

captura de pantalla 2016-12-21 a les 10 34 17

my angular-cli.json

{
"project": {
"version": "1.0.0-beta.22-1",
"name": "webapp-21b"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"download",
".well-known",
"robots.txt",
"sitemap.xml"
],
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.css",
"./css/main.scss",
"./css/buttons.scss",
"./css/forms.scss",
"./css/navbar.scss",
"./css/nouislider.scss",
"./css/mixins.scss",
"./css/spinner.scss",
"./css/utils.scss",
"./css/vars.scss"
],
"scripts": [
"./assets/js/noUiSlider.9.0.0/nouislider.min.js",
"./assets/js/wNumb.js"
],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"addons": [
],
"packages": [
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "scss",
"prefixInterfaces": false,
"inline": {
"style": false,
"template": false
},
"spec": {
"class": false,
"component": true,
"directive": true,
"module": false,
"pipe": true,
"service": true
}
}
}

@Meligy
Copy link
Contributor

Meligy commented Dec 23, 2016

The only files you may not want there are the .gz and .map files.

You can provide --sourcemap false (-sm false for short) to avoid generating .map files.

And you can provide --suppress-sizes true (no short form unfortunately) to avoid generating .gz files.

But note that --suppress-sizes true has a bug.
image
Bug:
--suppress-sizes true does not affect the vendor bundle (it does affect the main bundle).

A workaround is to pass --vendor-chunk false (again, no short form).
Which will take slightly longer, but might also give slightly more optimized bundle (not 100% sure).

Final output (assuming no assets or fonts etc referenced -- based on beta 24):

image

The command used for this output is:

ng build -prod -sm false --suppress-sizes true --vendor-chunk false

@Perezmarc
Copy link
Author

Thanks!

@filipesilva
Copy link
Contributor

Closing as @Meligy already gave a great answer, cheers!

@Meligy
Copy link
Contributor

Meligy commented Dec 30, 2016

@filipesilva there's still a bug with --suppress-sizes not working with vendor file.

That's the only open part from this issue.

@filipesilva
Copy link
Contributor

I actually have no idea what suppress-sizes is supposed to do. As far as I can tell, it's an option that's listed but never did anything. Also #1841

@Meligy
Copy link
Contributor

Meligy commented Dec 30, 2016

@filipesilva from what I can see, it eliminates generating .gz files in the production build. It does work with main and chunk bundles, but not vendor bundles for some reason.

@Meligy
Copy link
Contributor

Meligy commented Dec 30, 2016

Actually, I take that back. I tried all the commands again, and agree with @filipesilva , --supress-sizes seems to do nothing (explains why I couldn't track it when I was looking for how to supress .gz from vendor).

The behaviour that confused me was switching on and off vendor chunks at the same time.

With beta 24:

  • If you have vendor on, which is the default, you only get a .gz file for this vendor chunk. You don't get it for main.
  • If you have vendor off, you get a .gz file for the main bundle. You don't get it for the other chunks (if you use lazy loading and have other chunks).

This is interesting. It's pretty much what was asked to have in the issue anyway, except now I wonder "Where are my .gzs?" as I think we used to have a few more .gz files generated.

So, either delete the remaining .gz file, or bring back all of them, ideally with a flag to disable them, something like what I thought --suppress-sizes did but it doesn't.

One final word about --suppress-sizes. I think in the very very old days of the CLI, it used to output sizes to the terminal, it's probably a safe to delete now.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants