1

I have been banging my head against the desk on this for a few days now and can't figure out why I can't get webpack to output my bundle.js as a minified file. I've managed to get it smaller by playing with the uglify settings, but it still isn't minified, it looks like this;

enter image description here

This makes the file much larger than I think it should be, and it doesn't look right at all. It weighs in at 330kb. Here is some of the relevant webpack code:

  plugins: [
    new webpack.DefinePlugin({ 'process.env':{ 'NODE_ENV': JSON.stringify('production') } }),
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: { warnings: false },
      mangle: false,
      sourcemap: false,
      minimize: true,
      mangle: { except: ['$super', '$', 'exports', 'require', '$q', '$ocLazyLoad'] }
    }),
    new ExtractTextPlugin('src/assets/stylesheets/app.css', { allChunks: true })
  ]

I cannot figure out for the life of me how to get it condensed into one clean line/block of code. What am I doing wrong?

David Meents
  • 621
  • 4
  • 12
  • 1
    It seems it is keeping file comments. Have you tried to add the option `{ output: { comments: false } }`? – Nikos Paraskevopoulos Jun 28 '16 at 09:58
  • Thanks Nikos, that made a huge difference in the appearance of the code, took out all the comments of course. Maybe I have an unrealistic expectation for what the size of the file should be when it's minified, though? It's still 330kb, and takes up 11 lines in the unwrapped text editor. This about as good as I'm going to get you think? – David Meents Jun 28 '16 at 16:00
  • 1
    You cannot be sure, really. You could however try passing the minified (and/or the unminified) file through various other minifiers to check. E.g. the closure compiler from Google - there are others too I think. – Nikos Paraskevopoulos Jun 28 '16 at 18:38
  • Thanks again, after checking there it looks like it's about as compressed as it's going to get. – David Meents Jun 28 '16 at 19:59
  • Good to know that it helped :) – Nikos Paraskevopoulos Jun 28 '16 at 20:15
  • Possible duplicate of [compiled/minified jsx file is bigger than original file](http://stackoverflow.com/questions/36001565/compiled-minified-jsx-file-is-bigger-than-original-file) – Paul Sweatte Sep 06 '16 at 13:46

0 Answers0