123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import { defineConfig } from 'vite';
- import vue from '@vitejs/plugin-vue';
- import { resolve } from 'path';
- // const target = 'http://192.168.2.40:10099';
- // const target = 'http://192.168.2.17:10010';
- // const target = "http://127.0.0.1:10010";
- // const target = "http://192.168.2.178:10010";
- const target = 'http://47.101.180.183:10014';
- export default defineConfig({
- plugins: [vue({
- template: {
- compilerOptions: {
- isCustomElement: (tag) => tag === 'ww-open-data'
- }
- }
- })],
- optimizeDeps: {
- include: ['vue-draggable-plus']
- },
- server: {
- host: '0.0.0.0',
- port: 19123,
- open: true,
- proxy: {
- '/api': {
- // 这里的'/api'表示需要转发到的接口路径前缀
- target, // 将请求转发到的目标地址
- changeOrigin: true, // 支持跨域
- rewrite: (path) => path.replace(/^\/api/, '') // 去除请求路径中的'/api'前缀
- }
- }
- },
- resolve: {
- alias: {
- '@': resolve(__dirname, './src')
- },
- extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
- },
- css: {
- preprocessorOptions: {
- scss: {
- // additionalData: '@import "@/styles/global.scss";'
- additionalData: '@use "@/styles/global.scss" as *;', // 使用 @use 语法
- api: "modern-compiler"
- }
- }
- },
- build: {
- rollupOptions: {
- output: {
- entryFileNames: `assets/[name].${new Date().getTime()}.js`,
- chunkFileNames: `assets/[name].${new Date().getTime()}.js`,
- assetFileNames: `assets/[name].${new Date().getTime()}.[ext]`,
- compact: true,
- manualChunks: {
- vue: ['vue', 'vue-router', 'vuex'],
- echarts: ['echarts']
- }
- }
- }
- }
- });
|