86 lines
2.8 KiB
TypeScript
86 lines
2.8 KiB
TypeScript
/*
|
|
* @Author: 996555510 65213605+996555510@users.noreply.github.com
|
|
* @Date: 2025-05-22 10:12:42
|
|
* @LastEditors: 996555510 65213605+996555510@users.noreply.github.com
|
|
* @LastEditTime: 2025-05-23 15:55:37
|
|
* @FilePath: \IofTV-Screen-Vue3-master\vite.config.ts
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
*/
|
|
|
|
/// <reference types="vite/client" />
|
|
import type { UserConfig, ConfigEnv } from 'vite';
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import { resolve } from "path";
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
|
//https://github.com/element-plus/unplugin-element-plus/blob/HEAD/README.zh-CN.md
|
|
import ElementPlus from 'unplugin-element-plus/vite'
|
|
import {createHtmlPlugin} from 'vite-plugin-html';
|
|
export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
|
|
|
|
const viteEnv = loadEnv(mode, process.cwd());
|
|
|
|
return {
|
|
base: '/',
|
|
plugins: [
|
|
vue(),
|
|
AutoImport({ resolvers: [ElementPlusResolver()] }),
|
|
Components({ resolvers: [ElementPlusResolver()] }),
|
|
ElementPlus(),
|
|
createHtmlPlugin({
|
|
inject: {
|
|
data: {
|
|
injectMapScript: `<script src="./public/static/map_load.js"></script>`,
|
|
},
|
|
},
|
|
minify: true,
|
|
}),
|
|
// Compression({
|
|
// algorithm: 'gzip',
|
|
// test: /\.(js|css|html|json|svg|jpe?g|png|gif)$/i,
|
|
// threshold: 1024,
|
|
// deleteOriginalAssets: false
|
|
// }),
|
|
// svgr()
|
|
],
|
|
publicDir: "public",
|
|
build: {
|
|
outDir: 'dist',
|
|
assetsDir: 'static'
|
|
},
|
|
server: {
|
|
host: '0.0.0.0',
|
|
port: 8080,
|
|
open: true,
|
|
strictPort: false,
|
|
proxy: {
|
|
[viteEnv.VITE_APP_CONTROL_BASE_API]: {
|
|
target: 'http://172.16.1.133:8081/xjIotApi',
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(new RegExp(`^${viteEnv.VITE_APP_CONTROL_BASE_API}`), ''),
|
|
},
|
|
[viteEnv.VITE_APP_BASE_API]: {
|
|
target: 'http://172.16.1.133:8081/iotApi',
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(new RegExp(`^${viteEnv.VITE_APP_BASE_API}`), ''),
|
|
}
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
"@": resolve(__dirname, "./src"),
|
|
"components": resolve(__dirname, "./src/components"),
|
|
"api": resolve(__dirname, "./src/api")
|
|
},
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
additionalData: `@use "./src/assets/css/variable.scss" as *;`,
|
|
},
|
|
},
|
|
}
|
|
};
|
|
}); |