All Projects → mdsb100 → Gulp Wxa Copy Npm

mdsb100 / Gulp Wxa Copy Npm

Licence: mit
微信小程序gulp插件,解决npm包管理和babel-runtime

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Gulp Wxa Copy Npm

Gulp Traceur
Traceur is a JavaScript.next to JavaScript-of-today compiler
Stars: ✭ 172 (+212.73%)
Mutual labels:  gulp-plugin, npm-package
Node Native Ext Loader
Loader for Node native extensions
Stars: ✭ 51 (-7.27%)
Mutual labels:  npm-package
Noop Stream
Create a readable Node.js stream that produces no data (or optionally blank data) or a writable stream that discards data
Stars: ✭ 40 (-27.27%)
Mutual labels:  npm-package
React Use Api
Async HTTP request data for axios. Designed for diverse UI states, SSR and data pre-caching.
Stars: ✭ 49 (-10.91%)
Mutual labels:  npm-package
Wxapp
这是一个Sublime的插件, 用来开发<微信小程序>.
Stars: ✭ 42 (-23.64%)
Mutual labels:  wxapp
Nodereactionagent
NodeReactionAgent is an Node.js asynchronous performance monitoring tool to be in conjunction with Nodereaction.com or nodereactionclient
Stars: ✭ 49 (-10.91%)
Mutual labels:  npm-package
Actions Package Update
keeps npm dependencies up-to-date by making pull requests from GitHub Actions or CI.
Stars: ✭ 36 (-34.55%)
Mutual labels:  npm-package
Alfred Lock
Alfred 3 workflow to lock your Mac
Stars: ✭ 54 (-1.82%)
Mutual labels:  npm-package
Node Env Webpack Plugin
Simplified `NODE_ENV` handling with webpack
Stars: ✭ 51 (-7.27%)
Mutual labels:  npm-package
Pannellum React
React Component for Pannellum (open source panorama viewer for the web)
Stars: ✭ 48 (-12.73%)
Mutual labels:  npm-package
Autocomplete Wx
一款atom插件,支持微信语法高亮和代码补全
Stars: ✭ 47 (-14.55%)
Mutual labels:  wxapp
Taxjar Node
Sales Tax API Client for Node
Stars: ✭ 43 (-21.82%)
Mutual labels:  npm-package
Wxapp Img Loader
适用于微信小程序的图片预加载组件
Stars: ✭ 1,049 (+1807.27%)
Mutual labels:  wxapp
Is
Type check values
Stars: ✭ 1,011 (+1738.18%)
Mutual labels:  npm-package
Gulp Require Tasks
Splits Gulpfile into multiple individual files
Stars: ✭ 51 (-7.27%)
Mutual labels:  gulp-plugin
Create Wxapp Page
创建微信小程序页面的命令行工具
Stars: ✭ 37 (-32.73%)
Mutual labels:  wxapp
Generator Gulp Plugin Boilerplate
Scaffold out a Gulp plugin boilerplate
Stars: ✭ 46 (-16.36%)
Mutual labels:  gulp-plugin
Slugify Cli
Slugify a string
Stars: ✭ 49 (-10.91%)
Mutual labels:  npm-package
Capture Website
Capture screenshots of websites
Stars: ✭ 1,075 (+1854.55%)
Mutual labels:  npm-package
Sudolite
一款轻巧、趣萌、界面精美,具备统计、排行(即将推出),开源、免费、无广告的数独小程序
Stars: ✭ 52 (-5.45%)
Mutual labels:  wxapp

gulp-wxa-copy-npm

微信小程序gulp插件,解决npm包管理和babel-runtime。可以使用诸如ES7,moment等。

在package.json加入"babel-plugin-transform-runtime",在babel配置的plugins加入"transform-runtime"。这样就可以直接使用Promise,Map,Symbol等。

如果想要使用async await,甚至是Decorator,具体只要参考babel配置就可以了。

Usage

In gulpfile.js

const gulp = require("gulp");
const babel = require("gulp-babel");
const gwcn = require('gulp-wxa-copy-npm');
const sourcemaps = require('gulp-sourcemaps');

gulp.task('babel', () =>
    let knownOptions = {};

    let options = minimist(process.argv.slice(2), knownOptions);
    //config.babel
    gulp.src('src/**/*.js')
        .pipe(sourcemaps.init())
        .pipe(log('Babeling'))
        .pipe(babel({
          "presets": [
            "es2015",
            "stage-0"
          ],
          "plugins": [
            "transform-export-extensions",
            "syntax-export-extensions",
            "transform-runtime"
          ]
        }))
        .pipe(gwcn(options))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(config.dest));
);

在代码中:

const moment = require('moment'); //NPM
const util = require('./util');
import moment from 'moment' //NPM

import config from './config'
import {fetch} from '../common'

注意项目中的代码一定要使用require('./util')require('../common/page')这种形式。

Installation

$ npm install gulp-wxa-copy-npm --save-dev

Why

首先感谢labradorwepy参考了其中一些代码。这2个库很优秀!但是限制了我们。我们可以自己建gulpfile来使用stylus,imagemin等。可是最大的诉求是想用NPM包管理和ES7,没有这样的一个gulp插件。所以我就做了一个。

但是自由是有代价的,很多东西你需要自己写。

Directory

|- dist
|- src
|- gulpfile.js
\- package.json

Options

  • gwcn-src默认是'src'。表示的是:源目录夹名。
  • gwcn-dest默认是'dist'。表示的是:输出目录夹名。
  • node_modules默认是'../node_modules'。表示的是:源目录和node_modules相对路径。
  • gwcn-log默认是false。表示的是:是否输出log。
  • plugins。数组。

Plugin Example

const guglify = through.obj(function(file, enc, callback) {
    let code = file._contents.toString(enc);
    let result = uglify.minify(code, {
        fromString: true
    });
    file._contents = new Buffer(result.code);
    callback(null, file);
});

const task_babel_release = function() {
    let knownOptions = {};

    let options = minimist(process.argv.slice(2), knownOptions);
    options.plugins = [(code, destPath, {file, enc, callback}) => uglify.minify(code, {
        fromString: true
    }).code];

    //{file, enc, callback} 和through的保持一致

    return gulp.src(config.js)
        .pipe(log('Babeling'))
        .pipe(babel(config.babel))
        .pipe(guglify)
        .pipe(gwcn(options))
        .pipe(gulp.dest(config.dest));
};

Issues

目前版本还是0.1.3,没有经过充分测试。欢迎大家提bug和pull request!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].