const path = require('path'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const env = process.env.NODE_ENV; module.exports = { entry: './src/transport.js', output: { filename: 'transport.js', path: path.resolve(__dirname, 'dist'), }, module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: { loader: 'babel-loader', options: { presets: ['@babel/preset-env'], }, }, }, { test: /\.css$/, use: env === 'production' ? ExtractTextPlugin.extract({ fallback: 'style-loader', use: ['css-loader'], }) : ['style-loader', 'css-loader'], }, ], }, plugins: [ new HtmlWebpackPlugin({ template: path.join(__dirname, 'index.html'), }), new ExtractTextPlugin({ disable: env === 'development', filename: '[name].css', }), ], devtool: 'cheap-module-eval-source-map', devServer: { contentBase: path.join(__dirname, 'dist'), host: '0.0.0.0', port: 8888, disableHostCheck: true, }, };