const prod = process.env.NODE_ENV === 'production'; const HtmlWebpackPlugin = require('html-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); module.exports = { mode: prod ? 'production' : 'development', entry: './src/index.tsx', output: { path: __dirname + '/dist/', publicPath: '/' }, module: { rules: [ { test: /\.(ts|js)x?$/, exclude: /node_modules/, resolve: { extensions: ['.ts', '.tsx', '.js', '.json'], }, use: 'babel-loader', }, { test: /\.(css)$/, use: [MiniCssExtractPlugin.loader, "css-loader"], }, { test: /\.(s(a|c)ss)$/, use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'], }, ] }, devServer: { historyApiFallback: true }, devtool: prod ? undefined : 'source-map', plugins: [ new HtmlWebpackPlugin({ template: 'index.html', }), new MiniCssExtractPlugin(), ], };