Alcadur
Alcadur

Reputation: 685

Webpack production version

Is it possibile to figure out in config file what version of file will be created?

I have simple config file:

...
entry: {
      "./src/application.js": "./dev",
      "./src/application.min.js": "./dev"
},
module: {
   loaders: [{
        test: /application\.js/,
        loaders: ["uglify"]
      }]
},
output: {
    path: './',
    filename: "[name]"
}
...

If I run webpack it should be run only ./src/application.js and if I run webpack -p it should be run both (or only uglify version).

Upvotes: 0

Views: 114

Answers (1)

Alcadur
Alcadur

Reputation: 685

For me this was help full:

var ExtractTextPlugin = require("extract-text-webpack-plugin"),
    CompressionPlugin = require("compression-webpack-plugin");
    isProduction = process.argv.indexOf("-p") > -1,
    plugins = [
        new ExtractTextPlugin("[name].gz.css")
    ];

if(isProduction){
    plugins.push(new CompressionPlugin({
        asset: "{file}",
        regexp: /\.js$|\.css$/
    }));
}

and in module.exports change plugins to plugins: plugins

Upvotes: 1

Related Questions