zhgdyun/vue.config.js

101 lines
3.2 KiB
JavaScript
Raw Normal View History

2022-11-10 09:18:38 +08:00
const path = require("path");
2022-06-08 14:51:11 +08:00
// 代码压缩
const TerserPlugin = require("terser-webpack-plugin");
2024-11-22 17:21:49 +08:00
const {
2025-02-06 09:08:55 +08:00
UniverPlugin
2024-11-22 17:21:49 +08:00
} = require('@univerjs/webpack-plugin')
2022-11-10 09:18:38 +08:00
function addStyleResource(rule) {
2025-02-06 09:08:55 +08:00
rule
.use("style-resource")
.loader("style-resources-loader")
.options({
patterns: [
path.resolve(__dirname, "src/assets/style/var.less"), //全局引入的less文件
path.resolve(__dirname, "src/assets/style/longguang.less"), //全局引入的less文件--龙光地产
],
});
2022-06-08 14:51:11 +08:00
}
module.exports = {
2025-02-06 09:08:55 +08:00
// publicPath: process.env.NODE_ENV === "production" ? "/jxjgd" : "/jxjgd",//金林湾配置
publicPath: process.env.NODE_ENV === "production" ? "./" : "/",
filenameHashing: true,
devServer: {
2025-03-24 18:19:54 +08:00
// open: true,
2025-02-06 09:08:55 +08:00
disableHostCheck: true,
// host: 'localhost',
proxy: {
"/china": {
target: "http://122.112.239.62:9000",
changeOrigin: true,
pathRewrite: {
"^/china": "", //重写路径
},
},
2022-11-10 09:18:38 +08:00
},
},
2025-02-06 09:08:55 +08:00
pages: {
index: {
entry: "./src/pages/index/index.js",
template: "./src/pages/index/index.html",
filename: "index.html",
title: "机械设备管理平台",
},
equipmentCenter: {
entry: "./src/pages/equipmentCenter/equipmentCenter.js",
template: "./src/pages/equipmentCenter/equipmentCenter.html",
filename: "equipmentCenter.html",
title: "设备中台",
},
2022-06-08 14:51:11 +08:00
},
2025-02-06 09:08:55 +08:00
chainWebpack: (config) => {
const types = ["vue-modules", "vue", "normal-modules", "normal"];
types.forEach((type) =>
addStyleResource(config.module.rule("less").oneOf(type))
);
2022-06-08 14:51:11 +08:00
},
2025-02-06 09:08:55 +08:00
pluginOptions: {
"style-resources-loader": {
preProcessor: "stylus",
patterns: [
// 全局变量路径,不能使用路径别名
path.resolve(__dirname, "./src/assets/theme.less"),
],
},
2022-06-08 14:51:11 +08:00
},
2025-02-06 09:08:55 +08:00
productionSourceMap: false,
configureWebpack: {
plugins: [
new UniverPlugin(),
],
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
ecma: undefined,
warnings: false,
parse: {},
compress: {
drop_console: true,
drop_debugger: false,
pure_funcs: ["console.log"], // 移除console
},
},
}),
],
},
devtool: 'source map'
2022-06-08 14:51:11 +08:00
},
2025-02-06 09:08:55 +08:00
// configureWebpack: (config) => {
// Object.assign(config, {
// // 开发生产共同配置
// resolve: {
// alias: {
// '@': path.resolve(__dirname, './src'),
// '@c': path.resolve(__dirname, './src/components'),
// '@p': path.resolve(__dirname, './src/assets/j')
// } // 别名配置
// }
// })
// }
2024-11-22 17:21:49 +08:00
};