decla-red/frontend/webpack.config.js
2020-10-23 18:06:56 +02:00

88 lines
2.4 KiB
JavaScript

const CleanWebpackPlugin = require('clean-webpack-plugin').CleanWebpackPlugin;
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ScssConfigWebpackPlugin = require('scss-config-webpack-plugin');
const TsConfigWebpackPlugin = require('ts-config-webpack-plugin');
const HtmlWebpackInlineSVGPlugin = require('html-webpack-inline-svg-plugin');
const TerserJSPlugin = require('terser-webpack-plugin');
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
//const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
module.exports = {
devServer: {
host: '0.0.0.0',
disableHostCheck: true,
watchOptions: {
poll: true,
},
},
plugins: [
// Cleans the dist folder before the build starts
new CleanWebpackPlugin(),
new ScssConfigWebpackPlugin(),
// Generate a base html file and injects all generated css and js files
new HtmlWebpackPlugin({
template: './src/index.html',
inlineSource: '.(css)$',
}),
new HtmlWebpackInlineSourcePlugin(HtmlWebpackPlugin),
new HtmlWebpackInlineSVGPlugin({
inlineAll: true,
svgoConfig: [
{
removeViewBox: false,
},
],
}),
//new FaviconsWebpackPlugin('static/logo.svg'),
// SCSS Configuration for .css .module.css and .scss .module.scss files
// see https://github.com/namics/webpack-config-plugins/tree/master/packages/scss-config-webpack-plugin/config
// Multi threading typescript loader configuration with caching for .ts and .tsx files
// see https://github.com/namics/webpack-config-plugins/tree/master/packages/ts-config-webpack-plugin/config
new TsConfigWebpackPlugin(),
],
optimization: {
minimizer: [
new TerserJSPlugin({
test: /\.js$/,
exclude: /node_modules/,
terserOptions: {
keep_classnames: true,
},
}),
],
},
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
use: ['source-map-loader'],
},
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
options: { injectType: 'singletonStyleTag' },
},
'css-loader',
],
},
{
test: /\.svg/,
use: {
loader: 'svg-url-loader',
options: {},
},
},
{
test: /\.(png)$/,
use: {
loader: 'file-loader',
},
},
],
},
};