Skip to content
This repository was archived by the owner on Nov 5, 2019. It is now read-only.

Ability to minify raw files #1

Closed
davidgovea opened this issue Jul 23, 2013 · 3 comments
Closed

Ability to minify raw files #1

davidgovea opened this issue Jul 23, 2013 · 3 comments

Comments

@davidgovea
Copy link

script-loader uses raw-loader, so the require()'ed script does not undergo any processing.

It would be nice if the webpack --optimize-minimize would compress scripts loaded with script-loader.

I started toying with a 'minscript-loader' using uglify-js, which is pretty easy https://github.com/mishoo/UglifyJS2#the-simple-way
but I end up duplicating the code from script loader anyways, so there should be a better way.

@sokra
Copy link
Member

sokra commented Jul 23, 2013

Hey,

instead for writing a loader which is a combination of the script-loader and minimizing, you can use chaining of loaders: only write a minimize-loader (which just minimize) and combine it with the script loader "!script!minimize!./code.js"

A easier way is, as the script-loader is often used with libraries, provide minimized code "!script!./code.min.js".

The script-loader is something like a last option if you didn't find a way to use the code a module, which is recommended. Webpack does support many module types and you can use the imports-loader and exports-loader, so it should be possible in the most cases (If not, write an issue).

@sokra sokra closed this as completed Oct 29, 2013
@davidgovea
Copy link
Author

Just saw you closed this - after reading your comments, I was able to replace all script-loaders with variations on imports/exports. Sometimes I'll use it for a convenient first-draft and then optimize after inspecting the library. Planning to write an article about it.. so nice..

Thanks as always!

@sokra
Copy link
Member

sokra commented Oct 30, 2013

Sounds nice. I would love to see more blog posts about webpack... 😄

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

2 participants