@microprogram/plugin-components
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-beta.30 • Public • Published

@microprogram/plugin-wxapp-components

Install

# yarn
yarn add @microprogram/plugin-components

Usage

in gulpfile.js

const components = require('@microprogram/plugin-components');

return gulp.src(/path/to/miniprogramRoot + '**/*.wxml')
    .pipe(components({
      targetKey: "usingComponents",
      transformers: [
        {
          prefix: 'van-',
          getComponentPath: (componentName) => {
            return `@vant/weapp/${componentName}/index`
          }
        },
        {
          prefix: 'self-',
          getComponentPath: (componentName) => {
            return `../../components/${componentName}/index`
          }
        },
        {
          prefix: 'home-',
          getComponentPath: (componentName) => {
            return `./components/${componentName}/index`
          }
        }
      ]
    }))
    .pipe(gulp.dest(destPath))

Example

The following is the original file content .wxml file:

<van-button>Button</van-button>

.json file:

{
  "usingComponents": {}
}

When use this task, the json file will auto be changed to

{
  "usingComponents": {
    "van-button": "@vant/weapp/button/index"
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @microprogram/plugin-components

Weekly Downloads

0

Version

1.0.0-beta.30

License

MIT

Unpacked Size

6.98 kB

Total Files

5

Last publish

Collaborators

  • jserwang