初始化代码
This commit is contained in:
59
vite.config.js
Normal file
59
vite.config.js
Normal file
@ -0,0 +1,59 @@
|
||||
import {defineConfig} from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
// 导入 path
|
||||
import path from 'path'
|
||||
// pxToRem
|
||||
import postCssPxToRem from 'postcss-pxtorem'
|
||||
// svg
|
||||
import {createSvgIconsPlugin} from 'vite-plugin-svg-icons'
|
||||
|
||||
export default defineConfig({
|
||||
base: './',
|
||||
build: {
|
||||
outDir: 'protal_dist',
|
||||
// 打包时使用 terser 压缩代码
|
||||
// minify: 'terser',
|
||||
// 是否生成源映射文件,方便调试生产环境代码
|
||||
sourcemap: 'inline',
|
||||
},
|
||||
plugins: [
|
||||
vue(),
|
||||
createSvgIconsPlugin({
|
||||
// 指定 SVG 图标目录(绝对路径)
|
||||
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons/svg')],
|
||||
// 指定 symbolId 格式
|
||||
symbolId: 'icon-[dir]-[name]',
|
||||
// 自定义插入位置(可选)
|
||||
inject: 'body-last',
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
// 配置别名
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
_c: path.resolve(__dirname, './src/components'),
|
||||
},
|
||||
// 省略扩展名导入
|
||||
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
|
||||
},
|
||||
css: {
|
||||
// scss 全局变量的配置
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
additionalData: `@use "@/assets/styles/variable.scss" as *;`,
|
||||
api: 'modern-compiler',
|
||||
silenceDeprecations: ['legacy-js-api'],
|
||||
},
|
||||
},
|
||||
// pxToRem
|
||||
postcss: {
|
||||
plugins: [
|
||||
postCssPxToRem({
|
||||
// 1rem = 16px
|
||||
rootValue: 16,
|
||||
propList: ['*'], // 如果想要某些不适用rem,使用!名字即可
|
||||
}),
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user