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.
63 lines
1.4 KiB
63 lines
1.4 KiB
1 week ago
|
import { fileURLToPath, URL } from 'node:url';
|
||
|
|
||
|
import { defineConfig } from 'vite';
|
||
|
import vue from '@vitejs/plugin-vue';
|
||
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||
|
import { babel } from '@rollup/plugin-babel';
|
||
|
import postCssPxToRem from 'postcss-pxtorem';
|
||
|
// https://vitejs.dev/config/
|
||
|
export default defineConfig({
|
||
|
plugins: [
|
||
|
vue(),
|
||
|
vueJsx(),
|
||
|
babel({
|
||
|
babelHelpers: 'bundled',
|
||
|
presets: [['@babel/preset-env', { targets: '> 0.25%, not dead' }]],
|
||
|
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
|
||
|
exclude: [/\.css$/], // 排除 CSS 文件
|
||
|
}),
|
||
|
],
|
||
|
server: {
|
||
|
host: '0.0.0.0',
|
||
|
port: 3080,
|
||
|
proxy: {
|
||
|
'/api': {
|
||
|
target: 'http://localhost:5090',
|
||
|
changeOrigin: true,
|
||
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
// 生产环境打包配置
|
||
|
// 去除 console debugger
|
||
|
build: {
|
||
|
target: 'es2015', // Vite 默认将代码打包为 ES2015+
|
||
|
rollupOptions: {
|
||
|
output: {
|
||
|
format: 'es',
|
||
|
},
|
||
|
},
|
||
|
terserOptions: {
|
||
|
compress: {
|
||
|
drop_console: true,
|
||
|
drop_debugger: true,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
resolve: {
|
||
|
alias: {
|
||
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||
|
},
|
||
|
},
|
||
|
css: {
|
||
|
preprocessorOptions: {
|
||
|
scss: {
|
||
|
additionalData: '',
|
||
|
},
|
||
|
},
|
||
|
postcss: {
|
||
|
plugins: [postCssPxToRem({ rootValue: 37.5, propList: ['*'] })],
|
||
|
},
|
||
|
},
|
||
|
});
|