Quick build your app into AMD library, while retaining all the dependencies. Automatic building and rebooting the client.
npm install amd-pack -g
amd-pack.cmd [options]
amd-pack [options]
amd-pack -i ./path/to/root/file.js
amd-pack -o ./path/to/builded/module.js
amd-pack -n myCoolAMDModule
amd-pack -m // minify builded file (used uglify minifer).
amd-pack -w //watch all dependences in you module and rebuild if some file chenged.
amd-pack --ws //reload client after rebuild, worked only with --watch(or -w).
amd-pack --ws // show all options
// @arguments: pathToFile <string>, wrapperType <string>
var file = amdPack.include('./file.md', 'string');
console.log(file);
Include file like string.
Include file like function.
var builder = require('amd-pack');
builder()({
input: './dist/component.jsx',
output: './src/Slider.js',
name: 'Slider',
builders: [
{
ext: 'less',
action: 'loading',
handler: function(source, next){
setTimeout(function(){
console.log('Less');
next(source);
}, 10);
}
},
{
ext: 'jsx?',
action: 'loading',
handler: function(source, next){
console.log('JSX');
next(source);
}
},
{
action: 'packing',
handler: function(source, next){
console.log('packing');
next(source);
}
}
]
});
For skiping some file you need added RegExp string for some path.
var builder = require('amd-pack');
builder()({
input: './dist/component.jsx',
output: './src/Slider.js',
name: 'Slider',
skip: ['node_modules'], // skip all files from node_modules
builders: [
{
ext: 'less',
action: 'loading',
skip: ['slider-skins\\.less'] // skip all "slider-skins.less" in this builder
handler: function(source, next){
setTimeout(function(){
console.log('Less');
next(source);
}, 10);
}
},
{
ext: 'jsx?',
action: 'loading',
handler: function(source, next){
console.log('JSX');
next(source);
}
},
{
'action': 'packing',
handler: function(source, next){
console.log('packing');
next(source);
}
}
]
});
Commented out modules will not be added to the project! Modules loaded from node_modules will be fully added to the file, except for native modules!
|_ include
| |_ one.js
| |_ two.js
| |_ three.js
|
|_ lib
| |_ index.js
| |_ sub.js
|
|_ src
| |_ index.html
|
|_ server.js
node ./server.js
amd-pack -i ./lib/index.js -o ./src/test.js -n testModule -w --ws
amd-pack -input ./lib/index.js -output ./src/test.js -name testModule -watch --ws
amd-pack -i ./lib/index.js -o ./src/test.js -n testModule -w --ws -m
amd-pack -input ./lib/index.js -output ./src/test.js -name testModule -watch --ws --minify
(function (root, factory, getModules) {
var __Dependencies = getModules();
var require = function(name){
return __Dependencies[name];
}
if (typeof define === 'function' && define.amd) {
define([], function(){factory(require)});
} else if (typeof module === 'object' && module.exports) {
module.exports = factory(require);
} else {
root.undefined = factory(require);
}
}(this, function (require) {
var two = require('/amd-pack/test/include/two.js');
//var $ = require('jquery');
two();
return function(){
$('body').append('<div style="color: red;">It\'s worked!</div>');
}
}, function(){
var __Dependencies = {};
var require = function(name){
return __Dependencies[name];
}
var _exports = function(path, module){__Dependencies[path] = module};
//Module file: /amd-pack/test/include/one.js
(function(){
var module = {};
Object.defineProperty(module, 'exports', {
get: function(){
return {};
},
set: _exports.bind(null, '/amd-pack/test/include/one.js')
});
module.exports = function(){
console.log('one');
}
}());
//Module file: /amd-pack/test/include/two.js
(function(){
var module = {};
Object.defineProperty(module, 'exports', {
get: function(){
return {};
},
set: _exports.bind(null, '/amd-pack/test/include/two.js')
});
var one = require('/amd-pack/test/include/one.js');
module.exports = function(){
one();
console.log('two');
}
}());
return __Dependencies;
}));
Anton Vashurkin cronosfera2@gmail.com. (c) 2016.