You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
2.7 KiB
107 lines
2.7 KiB
import { fileURLToPath } from 'url' |
|
|
|
import { defineConfig, loadEnv } from 'vite' |
|
import vue from '@vitejs/plugin-vue' |
|
import path from 'path' |
|
|
|
import AutoImport from 'unplugin-auto-import/vite' |
|
import Components from 'unplugin-vue-components/vite' |
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' |
|
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' |
|
|
|
import { univerPlugin } from "@univerjs/vite-plugin"; |
|
|
|
|
|
// https://vitejs.dev/config/ |
|
export default ({ mode }) => { |
|
const env = loadEnv(mode, process.cwd()); |
|
return defineConfig({ |
|
base: env.VITE_BASE, |
|
define: { |
|
'process.env': env |
|
}, |
|
server: { |
|
host: '0.0.0.0', |
|
port: 5173, |
|
proxy: { |
|
'/api/v2/': { |
|
target: 'http://127.0.0.1:8080/', |
|
changeOrigin: true, |
|
rewrite: (p) => p.replace(/^\/api\/v2/, '') |
|
}, |
|
'/out-police-service/': { |
|
target: 'http://127.0.0.1:8080/', |
|
changeOrigin: true, |
|
rewrite: (p) => p.replace(/^\/out-polic-service/, '') |
|
}, |
|
|
|
} |
|
}, |
|
plugins: [ |
|
vue(), |
|
AutoImport({ |
|
imports: [ |
|
'vue', 'vue-router' |
|
], |
|
resolvers: [ElementPlusResolver()], |
|
}), |
|
Components({ |
|
directoryAsNamespace: true, |
|
resolvers: [ElementPlusResolver({ |
|
importStyle: "sass" |
|
})], |
|
}), |
|
createSvgIconsPlugin({ |
|
// 配置路劲在你的src里的svg存放文件 |
|
iconDirs: [fileURLToPath(new URL('./src/assets/icons', import.meta.url))], |
|
symbolId: 'local-icon-[name]' |
|
}), |
|
univerPlugin() |
|
], |
|
resolve: { |
|
// https://cn.vitejs.dev/config/#resolve-alias |
|
alias: { |
|
// 设置别名 |
|
'~/': `${path.resolve(__dirname, 'src')}/`, |
|
'@': path.resolve(__dirname, './src/') |
|
}, |
|
// https://cn.vitejs.dev/config/#resolve-extensions |
|
extensions: ['.js', '.ts'] |
|
}, |
|
css: { |
|
preprocessorOptions: { |
|
scss: { |
|
additionalData: `@use "src/style/theme.scss" as *;` |
|
}, |
|
}, |
|
|
|
}, |
|
build: { |
|
outDir: 'plugin', |
|
sourcemap: false, |
|
chunkSizeWarningLimit: 1500, |
|
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'], |
|
echarts: ['echarts'], |
|
}, |
|
}, |
|
}, |
|
terserOptions: { |
|
compress: { |
|
drop_console: true, |
|
drop_debugger: true, |
|
}, |
|
ie8: true, |
|
output: { |
|
comments: true, |
|
}, |
|
}, |
|
} |
|
}) |
|
}
|
|
|