/* * @Author: PoJun * @Date: 2022-02-25 09:15:23 * @LastEditors: PoJun * @LastEditTime: 2023-06-08 18:30:14 * @Message: Do not edit */ const { resolve, join } = require("path"); const CompressionPlugin = require("compression-webpack-plugin"); const CopyWebpackPlugin = require("copy-webpack-plugin"); //引入插件 module.exports = { publicPath: "./", productionSourceMap: false, devServer: { open: true, proxy: { "/api": { target: process.env.VUE_APP_BASE_API, ws: true, changeOrigin: true, pathRewrite: { "^/api": "" }, }, }, }, css: { extract: { ignoreOrder: true }, // 开启后热更新失效 // 是否开启 CSS source maps sourceMap: false, requireModuleExtension: true, loaderOptions: { less: { lessOptions: { javascriptEnabled: true, modifyVars: { hack: `true; @import "${join(__dirname, "./src/styles/theme.less")}"; `, }, }, }, }, }, configureWebpack: () => { if (process.env.NODE_ENV === "production") { return { plugins: [ new CompressionPlugin({ test: /\.js$|\.css/, // 匹配文件名字 threshold: 10240, // 对超过10k的数据进行压缩 deleteOriginalAssets: false, // 是否删除源文件 }), new CopyWebpackPlugin({ patterns: [ { from: resolve(__dirname, "./src/static"), to: "static", globOptions: { dot: true, gitignore: true, }, }, ], }), ], }; } }, };