Max
Max

Reputation: 15965

Webpack not producing minified output

I am using webpack to compile my JavaScripts into a single script that can be run in a browser. This works fine, but I would like to minify my scripts to save on space. I have tried minifying the scripts using the --optimize-minimize flag as well as the UglifyJs plugin. Neither seem to work. Here is the webpack command I'm using:

webpack --max-old-space-size=4000 --optimize-minimize app.js output

Here is my config file for webpack:

var path = require("path");
var webpack = require("webpack");

module.exports = {
    module: {
        loaders: [
            { 
                loader: "babel-loader",
                test: /\.jsx?$/, 
                exclude: /node_modules/, 
                query: {
                    cacheDirectory: true,
                    presets: ["react", "es2015"]
                }
            },
            {
                loader: "json-loader",
                test: /\.json$/,
                exclude: /node_modules/
            }
        ]
    },
    resolve: {
        root: process.env.NODE_PATH.split(path.delimiter)
    },
    plugins: [
        new webpack.optimize.UglifyJsPlugin({minimize: true})
    ]
};

Upvotes: 1

Views: 848

Answers (1)

Max
Max

Reputation: 15965

The reason for this was that output did not end with .js. So, the following command worked: webpack --max-old-space-size=4000 --optimize-minimize app.js output.js. Very strange.

Upvotes: 2

Related Questions