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

@tarox/plugin-init-app

v1.0.0-alpha.17

Published

Taro应用初始化插件

Downloads

5

Readme

Taro app初始化插件

功能

  • 自动扫描pages并合并到app.tsx中到pages配置项,可配置需要/不需要打包的页面
  • 自动扫描components并生成components/index.ts文件

安装

npm install taro-plugin-init-app -D

使用

小程序指定页面不打包

// config/index.js
const config = {
  plugins: [
    [
      // 入口文件初始化插件
      'taro-plugin-init-app',
      {
        // 配置首页路由
        homeRoute: 'pages/home/index',
        weapp: {
          pages: {
            // 指定不需要打包的页面
            excludes: [
              'pages/test/index',
              'pages/test/index2'
            ],
          }
        },
      },
    ],
  ]
}

小程序指定页面打包

// config/index.js
const config = {
  plugins: [
    [
      // 入口文件初始化插件
      'taro-plugin-init-app',
      {
        // 配置首页路由
        homeRoute: 'pages/home/index',
        weapp: {
          pages: {
            // 指定需要打包的页面
            includes: [
              'pages/home/index',
              'pages/user/index'
            ],
          }
        },
      },
    ],
  ]
}

h5指定页面不打包

// config/index.js
const config = {
  plugins: [
    [
      // 入口文件初始化插件
      'taro-plugin-init-app',
      {
        // 配置首页路由
        homeRoute: 'pages/home/index',
        h5: {
          pages: {
            // 指定不需要打包的页面
            excludes: [
              'pages/test/index',
              'pages/test/index2'
            ],
          }
        },
      },
    ],
  ]
}

h5指定页面打包

// config/index.js
const config = {
  plugins: [
    [
      // 入口文件初始化插件
      'taro-plugin-init-app',
      {
        // 配置首页路由
        homeRoute: 'pages/home/index',
        h5: {
          pages: {
            // 指定需要打包的页面
            includes: [
              'pages/home/index',
              'pages/user/index'
            ],
          }
        },
      },
    ],
  ]
}

指定小程序分包文件夹

支持 includesexcludes 配置,注意 includes 优先级较高,当 includesexcludes 同时存在时会忽略 excludes 配置。

const plugins = [
  [
    // 入口文件初始化插件
    'taro-plugin-init-app',
    {
      // 配置首页路由
      homeRoute: 'pages/home/index',
      subPackages: {
        // 不纳入分包的文件夹
        // excludes: [
        //  'assets',
        //  'components',
        //  'constants',
        //  'enums',
        //  'interceptors',
        //  'lib',
        //  'pages',
        //  'services',
        //  'store',
        //  'styles',
        //  'utils',
        //  'tencent-webim',
        // ],
        // 指定作为分包打包的文件夹
        includes: [
          'activity',
          'address',
          'assemble',
          'cart',
          'classify',
          'common',
          'couponCenter',
          'demo',
          'dm',
          'goods',
          'integral-mall',
          'live',
          'marketing',
          'medicalUser',
          'order',
          'platform',
          'prescription',
          'register',
          'shop',
          'userCenter',
          'webview'
        ]
      },
    },
  ],
]

指定打包为页面/组件的文件类型

通过 compSuffix 属性可指定需要扫描为页面/组件的文件后缀,未在此列的文件类型将会被过滤。

例如,如果你只想把 tsx 结尾的文件扫描为页面/组件,compSuffix 配置项应该像如下这样:

const plugins = [
  [
    'taro-plugin-init-app',
    {
      compSuffix: [ '.tsx' ],
    }
  ]
]