|
@@ -1,18 +1,18 @@
|
|
|
|
|
+import { fileURLToPath, URL } from 'node:url'
|
|
|
import { defineConfig } from 'vite'
|
|
import { defineConfig } from 'vite'
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
|
|
import Icons from 'unplugin-icons/vite'
|
|
import Icons from 'unplugin-icons/vite'
|
|
|
-import IconsResolver from 'unplugin-icons/resolvers'
|
|
|
|
|
-import path from 'path'
|
|
|
|
|
|
|
+import IconsResolver from 'unplugin-icons/resolver'
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
// https://vitejs.dev/config/
|
|
|
export default defineConfig({
|
|
export default defineConfig({
|
|
|
- base: './',
|
|
|
|
|
|
|
+ base: '/k_new_online/',
|
|
|
resolve: {
|
|
resolve: {
|
|
|
alias: {
|
|
alias: {
|
|
|
- '@': path.resolve(__dirname, './src')
|
|
|
|
|
|
|
+ '@': fileURLToPath(new URL('./src', import.meta.url))
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
plugins: [
|
|
plugins: [
|
|
@@ -26,7 +26,10 @@ export default defineConfig({
|
|
|
],
|
|
],
|
|
|
imports: [
|
|
imports: [
|
|
|
'vue',
|
|
'vue',
|
|
|
|
|
+ // 自定义全局引入
|
|
|
{
|
|
{
|
|
|
|
|
+ // 全局引入"src/api/index.ts"的`default`导出,注册为全局变量`api`
|
|
|
|
|
+ // 相当于在每个ts/vue文件中执行了一次 `import api from "@/api/index"`;
|
|
|
'@/api/index': [['default', '$api']]
|
|
'@/api/index': [['default', '$api']]
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
@@ -34,7 +37,7 @@ export default defineConfig({
|
|
|
}),
|
|
}),
|
|
|
Components({
|
|
Components({
|
|
|
resolvers: [
|
|
resolvers: [
|
|
|
- ElementPlusResolver(),
|
|
|
|
|
|
|
+ ElementPlusResolver(), // 自动注册图标组件
|
|
|
IconsResolver({
|
|
IconsResolver({
|
|
|
enabledCollections: ['ep']
|
|
enabledCollections: ['ep']
|
|
|
})
|
|
})
|
|
@@ -48,6 +51,7 @@ export default defineConfig({
|
|
|
port: 80,
|
|
port: 80,
|
|
|
hmr: true,
|
|
hmr: true,
|
|
|
open: true,
|
|
open: true,
|
|
|
|
|
+ // 设置 https 代理
|
|
|
proxy: {
|
|
proxy: {
|
|
|
'/api': {
|
|
'/api': {
|
|
|
target: 'http://192.168.0.161',
|
|
target: 'http://192.168.0.161',
|
|
@@ -55,14 +59,5 @@ export default defineConfig({
|
|
|
rewrite: (path: string) => path.replace(/^\/api/, '')
|
|
rewrite: (path: string) => path.replace(/^\/api/, '')
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
- build: {
|
|
|
|
|
- rollupOptions: {
|
|
|
|
|
- output: {
|
|
|
|
|
- entryFileNames: `[name].[hash].js`,
|
|
|
|
|
- chunkFileNames: `[name].[hash].js`,
|
|
|
|
|
- assetFileNames: `[name].[hash].[ext]`
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|