gulp-wxapp-components

1.0.2 • Public • Published

gulp-wxapp-components

Install

# yarn
yarn add gulp-wxapp-components
# may need `sudo`

Usage

in gulpfile.js

const components = require('gulp-wxapp-components');

return gulp.src(miniprogramRoot + '**/*.wxml')
    .pipe(components({
      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"
  }
}

Package Sidebar

Install

npm i gulp-wxapp-components

Weekly Downloads

7

Version

1.0.2

License

MIT

Unpacked Size

4.72 kB

Total Files

4

Last publish

Collaborators

  • jserwang