123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- import { defineConfig, loadEnv } from 'vite'
- import vue from '@vitejs/plugin-vue'
- import ViteComponents from 'unplugin-vue-components/vite'
- import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
- import DefineOptions from 'unplugin-vue-define-options/vite'
- import { chunkSplitPlugin } from 'vite-plugin-chunk-split';
- import { resolve } from 'path'
- // const proxy = {
- // '/api': {
- // target: 'https://v4-test.4dkankan.com/',
- // changeOrigin: true,
- // rewrite: path => path.replace(/^\/api/, '')
- // }
- // }
- // https://vitejs.dev/config/
- export default ({ mode }) =>
- defineConfig({
- base: './',
- plugins: [
- vue(),
- DefineOptions(),
- ViteComponents({
- resolvers: [
- AntDesignVueResolver({ resolveIcons: true, importStyle: 'less' })
- ],
- dts: 'src/components.d.ts'
- }),
- chunkSplitPlugin({
- strategy: 'default',
- customSplitting: {
- // `react` and `react-dom` 会被打包到一个名为`render-vendor`的 chunk 里面(包括它们的一些依赖,如 object-assign)
- 'vue-vendor': ['vue','pinia','vue-i18n','vue-router'],
- 'dept-vendor': ['ant-design-vue', '@ant-design/icons-vue'],
- // 源码中 utils 目录的代码都会打包进 `utils` 这个 chunk 中
- 'utils': ['echarts', 'lodash-es','vue3-autocounter']
- }
- })
- ],
- css: {
- preprocessorOptions: {
- less: {
- javascriptEnabled: true,
- modifyVars: {
- 'primary-color': '#0076F6',
- 'link-color': '#0076F6',
- 'border-radius-base': '2px'
- }
- }
- }
- },
- resolve: {
- alias: [
- {
- find: 'vue-i18n',
- replacement: 'vue-i18n/dist/vue-i18n.cjs.js'
- },
- {
- find: '@',
- replacement: resolve(__dirname, './src')
- },
- {
- find: '#',
- replacement: resolve(__dirname, './types')
- }
- ]
- },
- server: {
- host: '0.0.0.0',
- port: 5173,
- open: true,
- proxy: {
- '/api': {
- target: loadEnv(mode, process.cwd()).VITE_BASE_API_URL,
- changeOrigin: true,
- rewrite: path => path.replace(/^\/api/, '')
- }
- }
- },
- })
|