代码拉取完成,页面将自动刷新
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path"; //这个path用到了上面安装的@types/node
import viteCompression from "vite-plugin-compression"; // 打包压缩
import { changePackageVersion } from "./build/plugins"; // 版本信息
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
const baseConfig = require("./public/baseConfig.json");
export default defineConfig(({ command, mode, ssrBuild }) => {
return {
base: baseConfig.baseUrl, // 根路径
resolve: {
//这里进行配置别名
alias: {
"@": path.resolve("./src"), // @代替src
"#": path.resolve("./types"), // #代替types
},
},
server: {
host: "0.0.0.0", //置为 0.0.0.0 或者 true 将监听所有地址
// port: 8080, //开发服务器端口
open: true,
https: false,
proxy: {
"^/deviceApi": {
target: "http://192.168.1.215",
changeOrigin: true,
},
"^/rtspApi": {
target: "http://192.168.1.215",
changeOrigin: true,
},
"^/HSExtendInterface": {
target: "http://192.168.1.215",
changeOrigin: true,
},
"^/dapingApi": {
target: "http://192.168.1.215",
changeOrigin: true,
},
"^/energyApi": {
target: "http://192.168.1.215",
changeOrigin: true,
},
"^/v1/statistics": {
target: "http://192.168.1.215",
changeOrigin: true,
},
"^/planAPS": {
target: "http://192.168.100.12:8097",
changeOrigin: true,
},
// "/v1/carbon": {
// target: "http://192.168.100.11:8010",
// changeOrigin: true,
// },
// "^/three_model": { target: "http://110.185.170.62:8081", changeOrigin: true, },
// "^/publicData/": { target: "http://192.168.3.246", changeOrigin: true },
// "^/signalr-hubs/": { target: "http://192.168.3.246", changeOrigin: true },
// "^/message-center/": { target: "http://192.168.3.246", changeOrigin: true },
// "^/ssoLogin/": { target: "http://192.168.3.246", changeOrigin: true },
// "^/time": { target: "http://192.168.3.246", changeOrigin: true },
// "^/.*?/api/": { target: "http://192.168.3.246", changeOrigin: true },
// "^/.*?/components/.*?(min.js|min.js\\?v=\\d+)$": { target: "http://192.168.3.246", changeOrigin: true },
// '^/signalr-notification/signalr-hubs/notifications/realtime/negotiate': { target: "http://192.168.3.246", changeOrigin: true },
// '^/signalr-notification/signalr-hubs/notifications/realtime\?access_token': { target: "ws://http://192.168.3.246", changeOrigin: true, ws: true },// 代理 websockets 或 socket.io
},
},
build:
mode === "wc"
? {
target: "esnext",
// minify: 'terser',
outDir: "dist/component",
emptyOutDir: true,
lib: {
// Could also be a dictionary or array of multiple entry points
entry: "src/exports/index",
// entry: resolve(__dirname, 'lib/main.js'),
name: "wcLib",
formats: ["es"], //, 'umd', 'iife', 'cjs'
// the proper extensions will be added
fileName: (format, entryName) => {
return `wc-lib.${format}.js`;
},
},
rollupOptions: {
// 确保外部化处理那些你不想打包进库的依赖
// external: ['vue'],
// output: {
// // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
// globals: {
// vue: 'Vue',
// },
// },
},
}
: undefined,
define: {
"process.env": process.env,
},
plugins:
mode === "wc"
? [
// 打包插件
vue({
template: {
compilerOptions: {
// 将所有带短横线的标签名都视为自定义元素
isCustomElement: (tag) => {
return (
!["el-", "router-"].some((val) => tag.includes(val)) &&
tag.includes("-")
);
},
},
},
}),
AutoImport({ resolvers: [ElementPlusResolver()] }),
Components({ resolvers: [ElementPlusResolver()] }),
viteCompression(),
]
: [
vue({
template: {
compilerOptions: {
// 将所有带短横线的标签名都视为自定义元素
isCustomElement: (tag) => {
return (
!["el-", "router-"].some((val) => tag.includes(val)) &&
tag.includes("-")
);
},
},
},
}),
AutoImport({ resolvers: [ElementPlusResolver()] }),
Components({ resolvers: [ElementPlusResolver()] }),
changePackageVersion(),
],
// css处理
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "@/assets/styles/element/index.scss" as *;`,
},
},
postcss: {
plugins: [
// 处理打包时 "@charset" must be the first rule in the file 警告
{
postcssPlugin: "internal:charset-removal",
AtRule: {
charset: (atRule) => {
if (atRule.name === "charset") {
atRule.remove();
}
},
},
},
],
},
},
};
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。