mirror of
https://github.com/optim-enterprises-bv/Mailu.git
synced 2025-10-30 09:42:26 +00:00
My previous fix attempt only made it clear that the issue was in the runtime and an upstream issue with Webpack, but did not really fix things. Since Webpack 5.96.0, especially since420d0d0eedWebpack does not generate JS for asset chunks, which breaks having a single entry with both JS and asset chunks. The logo can easily be moved to a separate entry. (cherry picked from commit0a3f6e5c2f)
78 lines
2.1 KiB
JavaScript
78 lines
2.1 KiB
JavaScript
const path = require('path');
|
|
const webpack = require('webpack');
|
|
const css = require('mini-css-extract-plugin');
|
|
const mini = require('css-minimizer-webpack-plugin');
|
|
const terse = require('terser-webpack-plugin');
|
|
const compress = require('compression-webpack-plugin');
|
|
|
|
module.exports = {
|
|
mode: 'production',
|
|
entry: {
|
|
app: {
|
|
import: ['./assets/app.css', './assets/app.js'],
|
|
dependOn: 'vendor',
|
|
},
|
|
vendor: './assets/vendor.js',
|
|
logo: './assets/mailu.png',
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, 'static/'),
|
|
filename: '[name].js',
|
|
assetModuleFilename: '[name][ext]',
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.js$/,
|
|
use: ['babel-loader', 'import-glob'],
|
|
},
|
|
{
|
|
test: /\.s?css$/i,
|
|
use: [css.loader, 'css-loader', 'sass-loader'],
|
|
},
|
|
{
|
|
test: /\.less$/i,
|
|
use: [css.loader, 'css-loader', 'less-loader'],
|
|
},
|
|
{
|
|
test: /\.(json|png|svg|jpg|jpeg|gif)$/i,
|
|
type: 'asset/resource',
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
new css({
|
|
filename: '[name].css',
|
|
chunkFilename: '[id].css',
|
|
}),
|
|
new webpack.ProvidePlugin({
|
|
$: 'jquery',
|
|
jQuery: 'jquery',
|
|
ClipboardJS: 'clipboard',
|
|
}),
|
|
new compress({
|
|
filename: '[path][base].gz',
|
|
algorithm: "gzip",
|
|
exclude: /\.(png|gif|jpe?g)$/,
|
|
threshold: 5120,
|
|
minRatio: 0.8,
|
|
deleteOriginalAssets: false,
|
|
}),
|
|
],
|
|
optimization: {
|
|
minimize: true,
|
|
minimizer: [
|
|
new terse(),
|
|
new mini({
|
|
minimizerOptions: {
|
|
preset: [
|
|
'default', {
|
|
discardComments: { removeAll: true },
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
],
|
|
},
|
|
};
|