Skip to content
Snippets Groups Projects
webpack.config.prod.js 1.26 KiB
Newer Older
scmoritz's avatar
scmoritz committed
var webpack = require('webpack');
var CompressionPlugin = require('compression-webpack-plugin');

var config = {
    context: __dirname + '/src', // `__dirname` is root of project and `src` is source

    entry: './index.js',

    output: {
        path: __dirname + '/dist', // `dist` is the destination
        filename: 'bundle.js'
    },

    //To run development server
    devServer: {
        contentBase: __dirname,
        publicPath: '/dist',        
        compress: true,
        port: 9000,
        hot: true,
        index: "index.html"
scmoritz's avatar
scmoritz committed
    },

    module: {
        rules: [
            {
                test: /\.js$/, // Check for all js files
                exclude: /node_modules/,
                use: [{
                    loader: 'babel-loader',
scmoritz's avatar
scmoritz committed
                    options: { presets: ['env'] }
scmoritz's avatar
scmoritz committed
                }]
            }
        ]
    },

    plugins: [
        new webpack.optimize.UglifyJsPlugin(),
        new webpack.optimize.AggressiveMergingPlugin(),
        new CompressionPlugin({
            asset: "[path].gz[query]",
            algorithm: "gzip",
            test: /\.js$|\.css$|\.html$/,
            threshold: 10240,
            minRatio: 0.8
        })
    ],

    devtool: "" // No source map for production build
};

module.exports = config;