|
@@ -1,6 +1,7 @@
|
|
import { defineConfig } from 'vite'
|
|
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import styleImport, { VantResolve } from 'vite-plugin-style-import'
|
|
import styleImport, { VantResolve } from 'vite-plugin-style-import'
|
|
|
|
+import postCssPxToRem from "postcss-pxtorem"
|
|
import WindiCSS from 'vite-plugin-windicss'
|
|
import WindiCSS from 'vite-plugin-windicss'
|
|
import * as path from 'path'
|
|
import * as path from 'path'
|
|
|
|
|
|
@@ -8,13 +9,33 @@ import * as path from 'path'
|
|
// https://vitejs.dev/config/
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
export default defineConfig({
|
|
server: {
|
|
server: {
|
|
- host: true
|
|
|
|
|
|
+ port: 4500, // 设置服务启动端口号
|
|
|
|
+ open: true, // 设置服务启动时是否自动打开浏览器
|
|
|
|
+ cors: true // 允许跨域
|
|
|
|
+
|
|
|
|
+ // 设置代理,根据我们项目实际情况配置
|
|
|
|
+ // proxy: {
|
|
|
|
+ // '/api': {
|
|
|
|
+ // target: 'http://xxx.xxx.xxx.xxx:x000',
|
|
|
|
+ // changeOrigin: true,
|
|
|
|
+ // secure: false,
|
|
|
|
+ // rewrite: (path) => path.replace('/api/', '/')
|
|
|
|
+ // }
|
|
|
|
+ // },
|
|
},
|
|
},
|
|
|
|
+ base: './', // 设置打包路径
|
|
plugins: [
|
|
plugins: [
|
|
vue(),
|
|
vue(),
|
|
WindiCSS(),
|
|
WindiCSS(),
|
|
styleImport({
|
|
styleImport({
|
|
- resolves: [VantResolve()]
|
|
|
|
|
|
+ resolves: [VantResolve()],
|
|
|
|
+ libs: [
|
|
|
|
+ {
|
|
|
|
+ libraryName: 'vant',
|
|
|
|
+ esModule: true,
|
|
|
|
+ resolveStyle: component => `/node_modules/vant/es/${component}/style/index`,
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
})
|
|
})
|
|
],
|
|
],
|
|
resolve: {
|
|
resolve: {
|
|
@@ -29,5 +50,19 @@ export default defineConfig({
|
|
apis: path.resolve(__dirname, 'src/apis'),
|
|
apis: path.resolve(__dirname, 'src/apis'),
|
|
dirs: path.resolve(__dirname, 'src/directives')
|
|
dirs: path.resolve(__dirname, 'src/directives')
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ css: {
|
|
|
|
+ postcss: {
|
|
|
|
+ plugins: [
|
|
|
|
+ postCssPxToRem({
|
|
|
|
+ rootValue: 37.5, // Vant 官方根字体大小是 37.5
|
|
|
|
+ propList: ['*'],
|
|
|
|
+ selectorBlackList: ['.norem'] // 过滤掉.norem-开头的class,不进行rem转换
|
|
|
|
+ })
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
})
|
|
})
|