Skip to content
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

Minify assets for --release builds #7

Open
1 of 4 tasks
thedodd opened this issue Aug 25, 2020 · 10 comments
Open
1 of 4 tasks

Minify assets for --release builds #7

thedodd opened this issue Aug 25, 2020 · 10 comments
Labels
assets Build pipelines for specific asset types cli Trunk CLI application

Comments

@thedodd
Copy link
Member

thedodd commented Aug 25, 2020

This primarily applies to:

@thedodd thedodd added assets Build pipelines for specific asset types core labels Aug 25, 2020
@svenstaro
Copy link

How about also optimizing PNGs?

@thedodd
Copy link
Member Author

thedodd commented Aug 27, 2020

Sounds good to me. I’ll add it to the list above. Any ideas on libraries/algorithms we can use to accomplish this? I can’t say I’ve done much PNG optimization, I’d have to do some research on it.

@thedodd
Copy link
Member Author

thedodd commented Aug 27, 2020

We can add a new pipeline handler which handles PNGs specifically and does optimization as part of the pipeline.

@svenstaro
Copy link

Seems like oxipng is absolutely perfect for this task.

@thedodd thedodd added cli Trunk CLI application and removed core labels Sep 8, 2020
@MartinKavik
Copy link
Contributor

We need to minify also Rust/WASM.
For instance, the difference in *.wasm file size between wasm-pack and Trunk for one my Seed app is ~700 KB in release mode.
This minification is related to #5 because we would need to use wasm-opt.

@thedodd
Copy link
Member Author

thedodd commented Oct 16, 2020

@MartinKavik agreed. Release mode still makes a big difference, however there is no wasm-opt integration quite yet. We definitely need to get that added in.

@mpfaff
Copy link

mpfaff commented Jun 28, 2022

How about minifying the generated JavaScript?

@Carlrs
Copy link
Contributor

Carlrs commented Oct 23, 2022

Tried implementing this, but the JS minifiers I found on crates.io had problems - one broke wasm-bindgen generated JavaScript and the other couldn't parse it properly, but the author seems fairly active on github so I created an issue on his parser.

Will create pull request for CSS and HTML, but JS will have to wait and I feel that's the biggest bit.

@zstewar1
Copy link

What is the state of JS minifiers in trunk 18? The documentation on the website says that <script data-trunk ... copies scripts as-is. However I'm currently testing a project that uses hljs from an already minified bundle, which works in dev, but when I build it in prod, it becomes broken. The public name (hljs) gets minified away and one of the methods doesn't seem to exist, so code that depends on it just crashes.

@ctron
Copy link
Collaborator

ctron commented Dec 13, 2023

Trunk 0.18.0 adds minification of css and html too. If you find an issue I would ask you to raise a new issue, so that we can track it. At best, having a reproducer would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assets Build pipelines for specific asset types cli Trunk CLI application
Projects
None yet
Development

No branches or pull requests

7 participants