npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

uniapp-config

v1.1.2

Published

``` yarn add uniapp-config --dev ``` ## 项目配置 ``` js // 首先在项目根目录添加 uniapp.config.js // uniapp.config.js 内容 // 本地IDE配置,主要为了解决多人协作时提交Git冲突,所以设置一个本地配置,Git忽略即可 const localConfig = require('./uniapp.config.local.js')

Downloads

6

Readme

uniapp-config

这是一个node插件,主要实现对uni-app cli项目的自动化配置,含manifest.json配置修改,pages.json修改,tabBar图标修改等等,为一套项目经常需要切换不同公司配置,不同主题颜色而打造,告别手动改改改,切换配置时只需要切换相应代码即可一步到位(如:yarn set 001,切换到使用代号为001的配置)

安装

yarn add uniapp-config --dev

项目配置

// 首先在项目根目录添加 uniapp.config.js
// uniapp.config.js 内容
// 本地IDE配置,主要为了解决多人协作时提交Git冲突,所以设置一个本地配置,Git忽略即可
const localConfig = require('./uniapp.config.local.js')

module.exports = {
  manifestFile: 'src/manifest.json',
  configDir: 'src/config-hospital', // 配置存放的文件夹
  watchDir: 'src/config-hospital/中国', // 需要监听的文件夹
  defaultConfigFile: 'src/config-hospital/default.js', // 默认配置 根据情况配置 非必须
  mapFile: 'src/config-hospital/map.js', // 配置索引

  /**
   * @description 微信专属配置
   * version 上传代码版本号,每次上传理应修改
   */
  'mp-weixin': {
    version: '1.0.12',
    description: 'xxxxx小程序',
    ideDir: localConfig['mp-weixin'].ideDir
  },
  /**
   * @description 自定义扩展配置
   */
  extend: [
    {
      backUp: true, // 备份文件
      // uni-app 主配置文件
      configFile: './src/manifest.json',
      // 配置对应白名单
      setWhite: {
        'description': 'companyName',
        'mp-weixin.appid': 'platform.wx.appId',
        'mp-weixin.plugins': { path: 'platform.wx.plugins', default: {} },
        'mp-alipay.appid': 'platform.ali.appId'
      }
    },
    {
      // 页面配置
      backUp: true, // 备份文件
      configFile: './src/pages.json',
      setWhite: {
        '电子健康卡插件': {
          default: {},
          setPath: [
            'subPackages',
            val => val.root === 'pages/common',
            'pages',
            val => val.path === 'user-card/user-card',
            'style.mp-weixin.usingComponents'
          ],
          getPath: ['platform.wx.user-card/user-card.usingComponents']
        }
      }
    },
    {
      // 切换首页主题风格
      configFile: './src/pages/index/index.vue',
      watchFile: './src/pages/index/template',
      getConfigFile: config => {
        const theme = config.theme || 'default'
        return `./src/pages/index/template/${theme}.vue`
      },
      custom: ({ oldData, currentData, config } = {}) => {
        return currentData
      }
    }
  ]
}

插件命令

Options:
  -v, --version   当前版本
  -m, --minimize  压缩编译
  -w, --watch     监测文件变化,实时编译
  --view [key]    查看小程序当前或指定配置信息
  --set <key>     设置小程序配置信息为指定项
  --shell         执行uniapp运行命令 需要cross-env对应的uniapp一系列变量
  --map           查看小程序配置索引
  --open          打开小程序编译工具
  --upload        上传小程序
  -h, --help      查看帮助

命令配置

// package.json 添加运行命令

"scripts": {
    // 设置/修改配置 例:yarn set 001
    "set": "uniapp-config --set",

    // 查看当前使用配置或指定配置信息
    // 查看当前 yarn view
    // 查看指定 yarn view 001
    "view": "uniapp-config --view",

    // 查看uniapp-config命令
    "h": "uniapp-config --help",

    // 查看配置映射表
    // yarn map
    "map": "uniapp-config --map",
    
    // 如何使用
    // 替换调原有的命令 vue-cli-service uni-build
    cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin uniapp-config --shell --watch --open
}

示例

添加运行命令

参数

  • --shell 执行uniapp的原始命令
  • --watch 监听文件变化
  • --minimize 压缩小程序编译产物
  • --open 打开小程序编译工具 (目前仅支持微信小程序)
  • --upload 上传小程序代码 (目前仅支持微信小程序)

添加几个作为示例,其他端一样的

// wx:mini 等带mini的为压缩运行(非产品模式),主要解决开发模式下小程序体积包超出问题
"scripts": {
   "set": "uniapp-config --set",
   "view": "uniapp-config --view",
   "h": "uniapp-config --help",
   "map": "uniapp-config --map",
   "wx": "npm run dev:mp-weixin",
   "wx:mini": "npm run dev:mini:mp-weixin",
   "ali": "npm run dev:mp-alipay",
   "ali:mini": "npm run dev:mini:mp-alipay",
   "h5": "npm run dev:h5",
   "serve": "npm run dev:h5",
   "build": "npm run build:h5",
   "build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 uniapp-config --shell",
   "build:wx": "npm run build:mp-weixin",
   "build:ali": "npm run build:mp-alipay",
   "build:mp-alipay": "cross-env NODE_ENV=production UNI_PLATFORM=mp-alipay uniapp-config --shell --upload",
   "build:mp-weixin": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin uniapp-config --shell --upload",
   "dev:h5": "cross-env NODE_ENV=development UNI_PLATFORM=h5 uniapp-config --shell",
   "dev:mp-alipay": "cross-env NODE_ENV=development UNI_PLATFORM=mp-alipay uniapp-config --shell --watch --open",
   "dev:mini:mp-alipay": "cross-env NODE_ENV=development UNI_PLATFORM=mp-alipay uniapp-config --shell --watch --open --minimize",
   "dev:mp-weixin": "cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin uniapp-config --shell --watch --open",
   "dev:mini:mp-weixin": "cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin uniapp-config --shell --watch --open --minimize",
 }