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.ts', output: { filename: 'transport.js', path: path.resolve(__dirname, 'dist'), }, mode: env === 'production' ? 'production' : 'development', module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: { loader: 'babel-loader', options: { presets: [ '@babel/preset-env', ], plugins: [ '@babel/proposal-class-properties', '@babel/proposal-object-rest-spread', ], cacheDirectory: env === 'development', }, }, }, { test: /\.tsx?$/, use: 'ts-loader', exclude: /node_modules/, }, { test: /\.css$/, use: env === 'production' ? ExtractTextPlugin.extract({ fallback: 'style-loader', use: ['css-loader'], }) : ['style-loader', 'css-loader'], }, { test: /\.png$/, use: 'file-loader', }, ], }, resolve: { extensions: ['.tsx', '.ts', '.js'], }, 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, }, };