uglify捆绑文件并将它们都放在webpack中?

时间:2017-04-20 12:42:56

标签: javascript node.js webpack uglifyjs

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']
              }
          }
        }
      ]
    }

这是我的webpack配置,它在bundle.js目录中提供了dist文件。我想对此bundle.js进行说明,并希望bundle.jsbundle.min,js都出现在dist目录中。非常感谢帮助。

1 个答案:

答案 0 :(得分:1)

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
      })
    ]

试试这个并告诉我它是否有效!