import { optimize } from 'webpack'; import CompressionPlugin from 'compression-webpack-plugin'; const 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', }, module: { rules: [ { test: /\.js$/, // Check for all js files exclude: /node_modules/, use: [{ loader: 'babel-loader', options: { presets: ['env'] }, }], }, ], }, plugins: [ new optimize.UglifyJsPlugin(), new 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 }; export default config;