简体   繁体   中英

uglify bundle file and have them both in webpack?

entry: './app.js',
    output: {
      path: path.resolve(__dirname, 'dist'),
      filename: "bundle.js"
    },
    module: {
      rules: [
        {
          test: /\.js$/,
          exclude: /(node_modules)/,
          use: {
            loader: 'babel-loader',
              options: {
                presets: ['env', 'es2015', 'stage-2']
              }
          }
        }
      ]
    }

this is my webpack config and it gives me the bundle.js file in dist directory. I want to uglify this bundle.js and want both bundle.js and bundle.min,js be present in the dist directory. Help is very much appreciated.

entry: {
      'bundle': './app.js',
      'bundle.min': './dist/bundle.js',
    },

    output: {
      path: path.resolve(__dirname, 'dist'),
      filename: "[name].js"
    },

    plugins: [
      new webpack.optimize.UglifyJsPlugin({
      include: /\.min\.js$/,
      minimize: true
      })
    ]

Try this and let me know if it works!

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