import path from 'path'; import webpack from 'webpack'; // tslint:disable-next-line:no-var-requires const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const autoprefixer = require('autoprefixer'); const TerserPlugin = require('terser-webpack-plugin'); const config: webpack.Configuration = { mode: 'production', entry: { main: './assets/scripts/main.ts', }, output: { publicPath: '/', path: path.resolve(__dirname, 'static'), filename: '[name].js', }, resolve: { extensions: ['.ts', '.js'], }, module: { rules: [ { test: /\.tsx?$/, loader: 'ts-loader', options: { compilerOptions: { module: 'ES2020', }, }, }, { test: /\.scss$/, use: [ { loader: MiniCssExtractPlugin.loader, }, { loader: 'css-loader', options: { importLoaders: 1 } }, { loader: 'postcss-loader', }, { loader: 'sass-loader', }, ], }, ], }, plugins: [ new MiniCssExtractPlugin({ // Options similar to the same options in webpackOptions.output // both options are optional filename: '[name].css', chunkFilename: '[id].css', }), ], devtool: 'source-map', optimization: { usedExports: true, minimize: true, minimizer: [ new TerserPlugin({ terserOptions: { format: { comments: false, }, }, extractComments: false, }), ], }, }; export default config;