1.0.1 • Published 7 months ago

@lx-frontend/taro-plugin-modify-app-config v1.0.1

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
7 months ago

@lx-frontend/taro-plugin-modify-app-config

动态修改 app.config.ts 文件。

安装

在 Taro 项目根目录下安装

npm i @lx-frontend/taro-plugin-modify-app-config --save
pnpm add @lx-frontend/taro-plugin-modify-app-config

使用

引入插件

修改项目 config/dev.ts 中的 plugins 配置为如下

import type { UserConfigExport } from '@tarojs/cli'

export default {
  ...
  plugins: [
    // 用法1:直接传数组
    [
      '@lx-frontend/taro-plugin-modify-app-config',
      // 使用页面路径
      {
        pagesOrModifyFn: [
          'pages/chauffeur/submit/index'
        ]
      },
    ],
    // 用法2:修改函数
    [
      '@lx-frontend/taro-plugin-modify-app-config',
      // 使用页面路径
      {
        pagesOrModifyFn: (config) => {
          config.appConfig?.pages?.push?.(...[
            'pages/chauffeur/submit/index'
          ]);
          config.appConfig.subPackages = [];
        }
      },
    ],
  ],
  ...
} satisfies UserConfigExport