gulp-amd-wrap
v1.1.2
Published
![Language](https://img.shields.io/badge/-TypeScript-blue.svg) [![Build Status](https://travis-ci.org/searchfe/gulp-amd-wrap.svg?branch=master)](https://travis-ci.org/searchfe/gulp-amd-wrap) [![Coveralls](https://img.shields.io/coveralls/searchfe/gulp-amd
Downloads
46
Maintainers
Keywords
Readme
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`, {
// 工程baseUrl
base: __dirname,
},
).pipe(amdWrap({
baseUrl: '/assert/',
prefix: 'wiseindex/',
// 不参与amd-hook分析的文件
exelude: ['/exclude-**.js', '/dist/**'],
alias: [{
moduleId: 'debug',
path: 'util/debug',
prifix: false
}]
})).pipe(
gulp.dest(`${__dirname}\/dist\/`),
);
// Before
define(function() {
'use strict';
var fishObj = {
name: 'nimo'
};
var moduleA = require('@scope/moduleA');
var moduleB = require('./moduleB');
require(['A', './B', '/C', '@D/E', './util/debug'], function(a, b, c, d){
console.log(a, b, c, d);
});
return fishObj;
});
// After
define('wiseindex/assert/minify-define', [
'require',
'@scope/moduleA',
'wiseindex/assert/moduleB'
], function (require, moduleA, moduleB) {
'use strict';
var fishObj = { name: 'nimo' };
require([
'A',
'wiseindex/assert/B',
'/C',
'@D/E',
'debug'
], function (a, b, c, d) {
console.log(a, b, c, d);
});
return fishObj;
});