简体   繁体   中英

Webpack not uglifying/minifying

I'm using Webpack to build my site, but despite including the UglifyJsPlugin in the config, the output doesn't minify.

{
    entry: "./dist/client/js/index.js",
    devtool: "source-map",
    loaders: [
        {
            test: /\.js$/,
            loader: "babel",
            query: {
                cacheDirectory: false
            }
        }
    ],
    module: {
        preLoaders: [
            {
                test: /client\\.*\.js$/,
                loader: "source-map-loader"
            }
        ]
    },
    node: {
        child_process: "empty",
        dns: "empty",
        fs: "empty",
        net: "empty"
    },
    output: {
        path: JS_CLIENT_BUILD_PATH,
        filename: JS_BUNDLE_NAME
    },
    plugins: [new webpack.optimize.UglifyJsPlugin()]
}

Any ideas as to what I might be doing wrong?

I would try running webpack from the CLI with the -p argument. This essentially adds the Uglify plugin and sets the debug value to false. This should also minify the output. If the output is minified I would then point to something incorrect in your configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM