96 lines
2.1 KiB
TypeScript
96 lines
2.1 KiB
TypeScript
import { resolve } from 'path'
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
|
import Icons from 'unplugin-icons/vite'
|
|
import IconsResolver from 'unplugin-icons/resolver'
|
|
import Inspect from 'vite-plugin-inspect'
|
|
import pxtovw from 'postcss-px-to-viewport'
|
|
const loder_pxtovw = pxtovw({
|
|
// 这里是设计稿宽度 自己修改
|
|
viewportWidth: 1920,
|
|
viewportUnit: 'vw',
|
|
})
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd());
|
|
return {
|
|
css: {
|
|
postcss: {
|
|
// plugins: [loder_pxtovw],
|
|
},
|
|
},
|
|
server: {
|
|
port: 8080,
|
|
host: '0.0.0.0',
|
|
proxy: {
|
|
"/api": {
|
|
target: env.VITE_BASE_URL_API,
|
|
changeOrigin: true
|
|
},
|
|
"/draw": {
|
|
target: env.VITE_BASE_URL_DRAW_API,
|
|
changeOrigin: true
|
|
},
|
|
}
|
|
},
|
|
resolve: {
|
|
alias: [
|
|
{
|
|
find: '@',
|
|
replacement: resolve(__dirname, 'src'),
|
|
},
|
|
],
|
|
},
|
|
build: {
|
|
minify: 'terser',
|
|
terserOptions: {
|
|
compress: {
|
|
drop_console: true,
|
|
},
|
|
},
|
|
rollupOptions: {
|
|
output: {
|
|
chunkFileNames: 'assets/js/[name]-[hash].js',
|
|
entryFileNames: 'assets/js/[name]-[hash].js',
|
|
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
|
|
compact: true,
|
|
manualChunks: {
|
|
|
|
}
|
|
},
|
|
cache: true,
|
|
}
|
|
},
|
|
base: './', // 这里更改打包相对绝对路径
|
|
plugins: [
|
|
vue(),
|
|
AutoImport({
|
|
resolvers: [
|
|
ElementPlusResolver(),
|
|
IconsResolver({
|
|
prefix: 'Icon',
|
|
}),
|
|
],
|
|
}),
|
|
Components({
|
|
resolvers: [
|
|
ElementPlusResolver(),
|
|
IconsResolver({
|
|
enabledCollections: ['ep'],
|
|
}),
|
|
],
|
|
}),
|
|
Icons({
|
|
autoInstall: true,
|
|
}),
|
|
Inspect(),
|
|
],
|
|
|
|
}
|
|
}
|
|
)
|