12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import { defineConfig, loadEnv } from "vite";
- import vue from "@vitejs/plugin-vue";
- import path from "node:path";
- import { createHtmlPlugin } from 'vite-plugin-html';
- import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
- import { version } from './package.json'
- // https://vite.dev/config/
- export default ({ mode }: any) => {
- const env = loadEnv(mode, process.cwd())
- let proxy
- if (mode === 'development') {
- const getProxy = (prev: string, api: string) => ({
- target: api,
- changeOrigin: true,
- rewrite: (path: any) => path.replace(prev, '')
- })
- proxy = {
- ['/meshOSS']: getProxy('/meshOSS', 'https://4dkk.4dage.com/'),
- ['/meshAPI']: getProxy('/meshAPI', 'https://test.4dkankan.com/'),
- ['/cloudAPI']: getProxy('/cloudAPI', 'https://uat-laser.4dkankan.com/'),
- ['/fuseAPI']: getProxy('/fuseAPI', 'https://test-mix3d.4dkankan.com/'),
- }
- }
- return defineConfig({
- resolve: {
- alias: {
- "@/": `${path.resolve(__dirname, "src")}/`,
- },
- },
- css: {
- preprocessorOptions: {
- scss: {
- quietDeps: true,
- additionalData: `
- @forward 'element-plus/theme-chalk/src/common/var' with (
- $colors: (
- 'primary': (
- 'base': ${env.VITE_PRIMARY},
- ),
- ),
- );
- `,
- },
- },
- },
- server: {
- port: 9010,
- open: true,
- host: "0.0.0.0",
- proxy: proxy,
- },
- plugins: [
- createSvgIconsPlugin({
- iconDirs: [path.resolve(process.cwd(), 'public/icons')],
- symbolId: 'icon-[dir]-[name]'
- }),
- createHtmlPlugin({
- template: 'index.html',
- entry: path.resolve('src', env.VITE_ENTRY),
- inject: {
- data: {
- title: env.VITE_TITLE,
- },
- }
- }),
- vue()
- ],
- define: {
- __VERSION__: JSON.stringify(version)
- }
- });
- };
|