mirror of
https://gitlab.com/psono/psono-admin-client
synced 2025-04-19 03:22:17 +03:00
85 lines
2.2 KiB
JavaScript
85 lines
2.2 KiB
JavaScript
const { merge } = require('webpack-merge');
|
|
const common = require('./webpack.common.js');
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
const webpack = require('webpack');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const path = require('path');
|
|
|
|
module.exports = merge(common, {
|
|
mode: 'production',
|
|
devtool: 'source-map',
|
|
output: {
|
|
filename: 'static/js/[name].[contenthash:8].js',
|
|
chunkFilename: 'static/js/[name].[contenthash:8].chunk.js',
|
|
},
|
|
optimization: {
|
|
minimize: true,
|
|
minimizer: [
|
|
new TerserPlugin({
|
|
terserOptions: {
|
|
compress: {
|
|
comparisons: false,
|
|
},
|
|
mangle: {
|
|
safari10: true,
|
|
},
|
|
output: {
|
|
comments: false,
|
|
ascii_only: true,
|
|
},
|
|
},
|
|
}),
|
|
new CssMinimizerPlugin(),
|
|
],
|
|
splitChunks: {
|
|
chunks: 'all',
|
|
name: false,
|
|
},
|
|
runtimeChunk: {
|
|
name: (entrypoint) => `runtime-${entrypoint.name}`,
|
|
},
|
|
},
|
|
plugins: [
|
|
new webpack.DefinePlugin({
|
|
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
'process.env.PUBLIC_URL': JSON.stringify('/portal'),
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
filename: 'static/css/[name].[contenthash:8].css',
|
|
chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
|
|
}),
|
|
// Replace HtmlWebpackPlugin to use template processing
|
|
new HtmlWebpackPlugin({
|
|
inject: true,
|
|
template: path.resolve(__dirname, 'public/index.html'),
|
|
templateParameters: {
|
|
PUBLIC_URL: '/portal',
|
|
},
|
|
minify: {
|
|
removeComments: true,
|
|
collapseWhitespace: true,
|
|
removeRedundantAttributes: true,
|
|
useShortDoctype: true,
|
|
removeEmptyAttributes: true,
|
|
removeStyleLinkTypeAttributes: true,
|
|
keepClosingSlash: true,
|
|
minifyJS: true,
|
|
minifyCSS: true,
|
|
minifyURLs: true,
|
|
},
|
|
}),
|
|
],
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.css$/,
|
|
use: [
|
|
MiniCssExtractPlugin.loader,
|
|
'css-loader',
|
|
],
|
|
},
|
|
],
|
|
},
|
|
}); |