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

Compatibility with uglify plugin? #9

Closed
alexhancock opened this issue Jul 30, 2015 · 4 comments
Closed

Compatibility with uglify plugin? #9

alexhancock opened this issue Jul 30, 2015 · 4 comments

Comments

@alexhancock
Copy link

Is there a known issue with comments not being uglified out of modules being loaded with script-loader?

For instance, I have an entry file which looks like this...

// vendor.coffee
require("script!jquery/dist/jquery.min.js")
require("script!../assets/bootstrap/js/bootstrap.js")

...and a simplified version of my webpack config looks like this...

config =
  entry:
    vendor: "./vendor.coffee"
  plugins: [
    new webpack.optimize.UglifyJsPlugin({ output: {comments: false} }) // *
  ]

* using temporary solution for the structure of the comments output option from here

In this case, the resulting file still has a bunch of comments in it.

Am I missing something, or does uglify comment stripping just not work with files loaded with the script-loader? Are there other limitation when it comes to minification I should be aware of?

Thanks in advance for any help!

@alexhancock alexhancock changed the title Comments? Compatibility with uglify plugin? Jul 30, 2015
@gabrielhpugliese
Copy link

I have the exactly same issue. Was trying to change my build from gulp but the result becomes much bigger.

@alexhancock
Copy link
Author

I understand now, at least in part why it doesn't work. Given that the content of the files loaded with a script loader is just taken and wrapped in an eval.

I followed the advice here and wrote a simpler "uglify only" loader, which I will at least put on npm in case it's useful to someone else.

I also found this loader which I am experimenting with to see if it fits my needs.

I am trying to get source maps working, which I think the loader I just referenced achieves.

@gabrielhpugliese
Copy link

Oh yeah, that loader did the trick. But you need to put the script! before uglify! like this. because uglify needs to run before:

require('script!uglify!jquery-1.7.2.min.js');

Thanks!

@michael-ciniawsky
Copy link
Member

babel-loader && babel-preset-babili (Babel Minify) is also a (modern) option to achieve this, if there a any regressions still please reopen/open a new issue 😛

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