Browse Source

chore: 支持自定义主题

zhangyuhan 1 year ago
parent
commit
112c02685b
3 changed files with 13 additions and 5 deletions
  1. 2 1
      babel.config.js
  2. 10 3
      config/index.js
  3. 1 1
      src/assets/style/vant.theme.less

+ 2 - 1
babel.config.js

@@ -11,7 +11,8 @@ module.exports = {
     ['import', {
     ['import', {
       libraryName: 'vant',
       libraryName: 'vant',
       libraryDirectory: 'es',
       libraryDirectory: 'es',
-      style: true
+      // 指定样式路径
+      style: (name) => `${name}/style/less`,
     }, 'vant']
     }, 'vant']
   ]
   ]
 }
 }

+ 10 - 3
config/index.js

@@ -107,12 +107,19 @@ export default defineConfig(async (merge, { command, mode }) => {
       },
       },
     },
     },
     mini: {
     mini: {
-      // miniCssExtractPluginOption: {
-      //   ignoreOrder: true
-      // },
+      miniCssExtractPluginOption: {
+        ignoreOrder: true
+      },
       // optimizeMainPackage: {
       // optimizeMainPackage: {
       //   enable: true
       //   enable: true
       // },
       // },
+      lessLoaderOption: {
+        lessOptions: {
+          modifyVars: {
+            hack: 'true; @import "@/assets/style/vant.theme.less";'
+          },
+        },
+      },
       optimizeMainPackage: {
       optimizeMainPackage: {
         enable: false,
         enable: false,
         // exclude: [(module) => module.resource?.indexOf('miniprogram-sm-crypto') >= 0],
         // exclude: [(module) => module.resource?.indexOf('miniprogram-sm-crypto') >= 0],

+ 1 - 1
src/assets/style/vant.theme.less

@@ -22,7 +22,7 @@
 @button-normal-font-size: 16px;
 @button-normal-font-size: 16px;
 
 
 // Cell
 // Cell
-@cell-font-size: @font-size-lg;
+@cell-font-size: 16px;
 @cell-right-icon-color: #c0c4cc;
 @cell-right-icon-color: #c0c4cc;
 
 
 // Dialog var reset
 // Dialog var reset