gulp-amd-wrap
gulp-amd-wrap是一个分析amd模块,并进行预编译处理的的gulp插件,主要完成根据依赖分析及项目路径生成模块声明及引用的moduleID,并封装成amd规范的模块。
Install
npm i gulp-amd-wrap --save-dev
Example
import { amdWrap } from 'gulp-amd-wrap';
gulp.src(
`${__dirname}\/assert/*.js`, {
base: __dirname,
},
).pipe(amdWrap({
baseUrl: '/assert/',
prefix: 'wiseindex/',
exlude: ['/exclude-**.js', '/dist/**'],
moduleID: {
'moduleID': 'filepath'
}
})).pipe(
gulp.dest(`${__dirname}\/dist\/`),
);
define(function() {
'use strict';
var fishObj = {
name: 'nimo'
};
var moduleA = require('@scope/moduleA');
var moduleB = require('./moduleB');
require(['A', './B', '/C', '@D/E'], function(a, b, c, d){
console.log(a, b, c, d);
});
return fishObj;
});
define('assert/minify-define', [
'require',
'@scope/moduleA',
'assert/moduleB'
], function (require, moduleA, moduleB) {
'use strict';
var fishObj = { name: 'nimo' };
require([
'A',
'assert/B',
'/C',
'@D/E'
], function (a, b, c, d) {
console.log(a, b, c, d);
});
return fishObj;
});
API
API DOC