moner.ooo/webpack.config.js

55 lines
1.3 KiB
JavaScript
Raw Normal View History

'use strict';
2024-05-24 14:48:12 +00:00
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { PurgeCSSPlugin } = require('purgecss-webpack-plugin');
const glob = require('glob-all');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
2024-05-24 14:48:12 +00:00
module.exports = {
mode: 'production',
2024-05-24 14:48:12 +00:00
entry: './src/js/main.js',
output: {
filename: '[name].js',
2024-05-24 14:48:12 +00:00
path: path.resolve(__dirname, 'js'),
},
module: {
rules: [
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader'
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: '../css/[name].css'
}),
new PurgeCSSPlugin({
paths: glob.sync([
path.join(__dirname, 'index.php'),
path.join(__dirname, 'src/js/**/*.js')
]),
only: ['bootstrap'],
safelist: ['tooltip', 'fade', 'show', 'bs-tooltip-top', 'tooltip-inner', 'tooltip-arrow', 'btn-equals', 'btn-arrow', 'alert', 'alert-warning']
})
],
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: true,
},
},
}),
new CssMinimizerPlugin(),
],
}
};