mirror of
https://github.com/Telecominfraproject/wlan-cloud-ui.git
synced 2025-10-30 18:27:58 +00:00
133 lines
3.2 KiB
JavaScript
133 lines
3.2 KiB
JavaScript
/* eslint-disable import/no-extraneous-dependencies */
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
const path = require('path');
|
|
|
|
const commonPaths = require('./paths');
|
|
|
|
module.exports = {
|
|
output: {
|
|
path: commonPaths.outputPath,
|
|
publicPath: '/',
|
|
filename: `${commonPaths.jsFolder}/[name].[chunkhash].js`,
|
|
chunkFilename: `${commonPaths.jsFolder}/[id].[chunkhash].js`,
|
|
},
|
|
|
|
optimization: {
|
|
minimize: true,
|
|
minimizer: [
|
|
new TerserPlugin({
|
|
terserOptions: {
|
|
warnings: false,
|
|
compress: {
|
|
comparisons: false,
|
|
},
|
|
parse: {},
|
|
mangle: true,
|
|
output: {
|
|
comments: false,
|
|
ascii_only: true,
|
|
},
|
|
},
|
|
parallel: true,
|
|
}),
|
|
new CssMinimizerPlugin(),
|
|
],
|
|
nodeEnv: 'production',
|
|
sideEffects: true,
|
|
concatenateModules: true,
|
|
runtimeChunk: 'single',
|
|
splitChunks: {
|
|
chunks: 'all',
|
|
maxInitialRequests: 10,
|
|
minSize: 0,
|
|
cacheGroups: {
|
|
vendor: {
|
|
test: /[\\/]node_modules[\\/]/,
|
|
name(module) {
|
|
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
|
|
return `npm.${packageName.replace('@', '')}`;
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.(css|scss)$/,
|
|
use: [
|
|
MiniCssExtractPlugin.loader,
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
sourceMap: false,
|
|
localsConvention: 'camelCase',
|
|
modules: {
|
|
localIdentName: '[local]___[hash:base64:5]',
|
|
},
|
|
},
|
|
},
|
|
'sass-loader',
|
|
],
|
|
},
|
|
{
|
|
test: /\.less$/,
|
|
use: [
|
|
MiniCssExtractPlugin.loader,
|
|
{
|
|
loader: 'css-loader',
|
|
},
|
|
{
|
|
loader: 'less-loader', // compiles Less to CSS
|
|
options: {
|
|
lessOptions: {
|
|
javascriptEnabled: true,
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
|
|
resolve: {
|
|
modules: ['node_modules', 'app'],
|
|
alias: {
|
|
app: path.resolve(__dirname, '../', 'app'),
|
|
},
|
|
},
|
|
|
|
plugins: [
|
|
new CleanWebpackPlugin(),
|
|
|
|
// Minify and optimize the index.html
|
|
new HtmlWebpackPlugin({
|
|
template: commonPaths.templatePath,
|
|
favicon: './app/images/favicon.ico',
|
|
minify: {
|
|
removeComments: true,
|
|
collapseWhitespace: true,
|
|
removeRedundantAttributes: true,
|
|
useShortDoctype: true,
|
|
removeEmptyAttributes: true,
|
|
removeStyleLinkTypeAttributes: true,
|
|
keepClosingSlash: true,
|
|
minifyJS: true,
|
|
minifyCSS: true,
|
|
minifyURLs: true,
|
|
},
|
|
inject: true,
|
|
}),
|
|
|
|
new MiniCssExtractPlugin({
|
|
filename: `${commonPaths.cssFolder}/[name].css`,
|
|
chunkFilename: `${commonPaths.cssFolder}/[id].css`,
|
|
}),
|
|
],
|
|
};
|