const path = require('path'); const CleanWebpackPlugin = require('clean-webpack-plugin').CleanWebpackPlugin; const HtmlWebpackPlugin = require('html-webpack-plugin'); const TsConfigWebpackPlugin = require('ts-config-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin'); const HtmlWebpackInlineSVGPlugin = require('html-webpack-inline-svg-plugin'); const Sass = require('sass'); const PATHS = { entryPoint: path.resolve(__dirname, 'src/index.ts'), entryHtml: path.resolve(__dirname, 'src/index.html'), bundles: path.resolve(__dirname, 'dist'), }; module.exports = { entry: { index: PATHS.entryPoint, }, target: 'web', output: { path: PATHS.bundles, }, //devtool: 'source-map', watchOptions: { aggregateTimeout: 600, ignored: /node_modules/, }, devServer: { host: '0.0.0.0', disableHostCheck: true, }, plugins: [ new CleanWebpackPlugin(), new MiniCssExtractPlugin(), new HtmlWebpackPlugin({ xhtml: true, template: PATHS.entryHtml, minify: { collapseWhitespace: true, removeComments: true, removeRedundantAttributes: true, removeScriptTypeAttributes: true, removeStyleLinkTypeAttributes: true, useShortDoctype: true, }, inlineSource: '.(js|css)$', }), new HtmlWebpackInlineSourcePlugin(HtmlWebpackPlugin), new HtmlWebpackInlineSVGPlugin({ inlineAll: true, }), new TsConfigWebpackPlugin(), ], module: { rules: [ { test: /\.scss$/, use: [ MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', { loader: 'resolve-url-loader', options: { keepQuery: true, }, }, { loader: 'sass-loader', options: { sourceMap: true, implementation: Sass, }, }, ], }, { test: /\.(ico|png)$/, use: { loader: 'file-loader', query: { outputPath: '/', name: '[name].[ext]', }, }, }, { test: /no-change.*$/i, use: { loader: 'file-loader', query: { outputPath: '/', name: '[name].[ext]', }, }, }, { test: /\.(svg)$/, use: { loader: 'file-loader', query: { outputPath: '/', name: '[name].[ext]', }, }, }, { test: /\.js$/, enforce: 'pre', use: ['source-map-loader'], }, ], }, resolve: { extensions: ['.ts', '.js'], }, };