const path = require('path'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const devMode = process.env.NODE_ENV !== 'production'; module.exports = { entry: './src/index.tsx', module: { rules: [ { test: /\.tsx?$/, use: 'ts-loader', exclude: /node_modules/, }, { // Apply rule for .sass, .scss or .css files test: /\.s?css$/, // Set loaders to transform files. // Loaders are applying from right to left(!) // The first loader will be applied after others use: [ { // After all CSS loaders we use plugin to do his work. // It gets all transformed CSS and extracts it into separate // single bundled file loader: MiniCssExtractPlugin.loader }, { // This loader resolves url() and @imports inside CSS loader: 'css-loader', }, { // First we transform SASS to standard CSS loader: 'sass-loader' } ] }, ], }, plugins: [ new MiniCssExtractPlugin({ filename: 'bundle.css' }) ], resolve: { extensions: [ '.tsx', '.ts', '.js' ], }, output: { filename: 'bundle.js', path: path.resolve(__dirname, 'build'), }, mode: 'development' };