|
@@ -1,4 +1,4 @@
|
|
-import { defineConfig } from 'vite'
|
|
|
|
|
|
+import { defineConfig, loadEnv } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
import path from 'path'
|
|
import path from 'path'
|
|
@@ -10,57 +10,45 @@ function resolve(dir) {
|
|
return path.join(__dirname, dir)
|
|
return path.join(__dirname, dir)
|
|
}
|
|
}
|
|
|
|
|
|
-export default defineConfig({
|
|
|
|
|
|
+export default defineConfig(({ command, mode }) => {
|
|
|
|
+ // 加载env文件
|
|
|
|
+ const env = loadEnv(mode, process.cwd(), '')
|
|
|
|
+
|
|
|
|
+ return {
|
|
plugins: [
|
|
plugins: [
|
|
- vue(),
|
|
|
|
- vueJsx()
|
|
|
|
|
|
+ vue(),
|
|
|
|
+ vueJsx()
|
|
],
|
|
],
|
|
- define: {
|
|
|
|
- 'process.env': {
|
|
|
|
- BASE_URL: '/',
|
|
|
|
- NODE_ENV: process.env.NODE_ENV,
|
|
|
|
- API_URL: 'http://your-api-url',
|
|
|
|
- // ... 其他环境变量
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- css: {
|
|
|
|
- preprocessorOptions: {
|
|
|
|
- less: {
|
|
|
|
- javascriptEnabled: true,
|
|
|
|
- additionalData: `@import "${path.resolve(__dirname, 'src/app.less')}";`
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
resolve: {
|
|
resolve: {
|
|
- alias: {
|
|
|
|
- '@': resolve('src'),
|
|
|
|
- '@api': resolve('src/api'),
|
|
|
|
- '@assets': resolve('src/assets'),
|
|
|
|
- '@layouts': resolve('src/layouts'),
|
|
|
|
- '@static': resolve('src/static'),
|
|
|
|
- '@components': resolve('src/components'),
|
|
|
|
- '@router': resolve('src/router'),
|
|
|
|
- '@utils': resolve('src/utils'),
|
|
|
|
- '@store': resolve('src/store'),
|
|
|
|
- '@views': resolve('src/views')
|
|
|
|
- },
|
|
|
|
- extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.vue']
|
|
|
|
|
|
+ alias: {
|
|
|
|
+ '@': resolve('src'),
|
|
|
|
+ '@api': resolve('src/api'),
|
|
|
|
+ '@assets': resolve('src/assets'),
|
|
|
|
+ '@layouts': resolve('src/layouts'),
|
|
|
|
+ '@static': resolve('src/static'),
|
|
|
|
+ '@components': resolve('src/components'),
|
|
|
|
+ '@router': resolve('src/router'),
|
|
|
|
+ '@utils': resolve('src/utils'),
|
|
|
|
+ '@store': resolve('src/store'),
|
|
|
|
+ '@views': resolve('src/views')
|
|
|
|
+ },
|
|
|
|
+ extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.vue']
|
|
},
|
|
},
|
|
server: {
|
|
server: {
|
|
- port: 8003,
|
|
|
|
- proxy: {
|
|
|
|
- '/WebSocketConfig/': {
|
|
|
|
- target: 'ws://test.com',
|
|
|
|
- changeOrigin: true,
|
|
|
|
- ws: true,
|
|
|
|
- },
|
|
|
|
- '/api/': {
|
|
|
|
- target: 'http://test.com',
|
|
|
|
- changeOrigin: true,
|
|
|
|
- ws: false,
|
|
|
|
- }
|
|
|
|
|
|
+ port: 8003,
|
|
|
|
+ proxy: {
|
|
|
|
+ '/WebSocketConfig/': {
|
|
|
|
+ target: 'ws://test.com',
|
|
|
|
+ changeOrigin: true,
|
|
|
|
+ ws: true,
|
|
|
|
+ },
|
|
|
|
+ '/api/': {
|
|
|
|
+ target: 'http://test.com',
|
|
|
|
+ changeOrigin: true,
|
|
|
|
+ ws: false,
|
|
}
|
|
}
|
|
|
|
+ }
|
|
},
|
|
},
|
|
- productionSourceMap: false,
|
|
|
|
- lintOnSave: false,
|
|
|
|
|
|
+ base: '/',
|
|
|
|
+ }
|
|
})
|
|
})
|