const path = require('path') const MiniCssExtractPlugin = require('mini-css-extract-plugin') const CssMinimizerPlugin = require('css-minimizer-webpack-plugin') module.exports = { entry: './js-src/index.tsx', mode: 'production', devtool: 'source-map', plugins: [ new MiniCssExtractPlugin({ filename: '[name].css', chunkFilename: '[id].css' }) ], output: { filename: '[name].bundle.js', path: path.resolve(__dirname, 'public/js/'), libraryTarget: 'umd', library: 'main', umdNamedDefine: true }, resolve: { extensions: ['.js', '.jsx', '.ts', '.tsx'], roots: [ path.resolve(__dirname, 'js-src/') ], alias: { '@owlads': path.resolve(__dirname, 'js-src') } }, module: { rules: [ { test: /\.s[ac]ss$/i, use: [ 'style-loader', 'css-loader', 'sass-loader' ] }, { test: /\.css$/i, use: [MiniCssExtractPlugin.loader, 'css-loader'] }, { test: /\.tsx?$/, use: 'ts-loader', exclude: /node_modules/ }, { test: /\.jpe?g|png$/, exclude: /node_modules/, use: ['url-loader', 'file-loader'] }, { test: /\.(js|jsx)$/, exclude: /node_modules/, loader: 'babel-loader' } ] }, optimization: { minimizer: [ '...', new CssMinimizerPlugin() ], } }