Webpack.config.js default template

Posted 2 years ago

let webpack = require('webpack');
module.exports = {
  context: __dirname,
  entry: "./main.js",
  watch:true,
  output: {
    path: __dirname + "/js",
    filename: "main.min.js"
  },
  module: {
     loaders: [
    {
     test: /\.jsx?$/,
     exclude: /node_modules/,
     loader: 'babel',
     query: {
       presets: ['es2015', 'react']
     }
    }
   ]
 },
  plugins: [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
    new webpack.DefinePlugin({
      "process.env": {
        NODE_ENV: JSON.stringify("production")
      }
    })
  ],
};