esedic
9/20/2018 - 7:10 PM

A basic ES2015 Webpack Configuration with Uglification

A basic ES2015 Webpack Configuration with Uglification

var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');

module.exports = {
    entry: './src/main.js',
    output: {
        path: './dist/',
        filename: 'bundle.js'
    },
    module: {
        loaders: [
            {
                loader: 'babel-loader',
                test: /\.js/,
                query: {
                  presets: 'es2015',
                },
            }
        ]
    },
    plugins: debug ? [] : [
        new webpack.optimize.DedupePlugin(),
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
    ],
    // Create Sourcemaps for the bundle
    devtool: 'source-map',
};