2
0
Fork 0

fill readme

This commit is contained in:
Willem 2015-02-24 12:39:38 +01:00
parent 5de82aafd6
commit 7b1af6590e
2 changed files with 106 additions and 3 deletions

103
README.md
View file

@ -1 +1,102 @@
todo
node-ff-assets
=========
A small library providing automatic site assets local/remote aggregation with minify.
## Installation
npm install node-ff-assets --save
## Usage
// Create config object;
var buildConfig = {
downloadStartDelay: null,
downloadForce: false,
downloadOptions: {
timeout: 10000,
maxResponseLength: 10000000,
agent: 'node-ff-assets asset fetcher'
},
linkTargetSingleResult: true,
linkTarget: null,
linkSources: [],
linkMapping: [],
assetHeader: '\n/* node-ff-assets: begin */\n\n',
assetFooter: '\n/* node-ff-assets: end */\n\n',
assetSeperator: '\n/* node-ff-assets: next */\n',
}
// Create builder
var NodeFFAssets = require('node-ff-assets');
var assetBuilderA = new NodeFFAssets.ResourceBuilder(buildConfig);
var assetBuilderB = new NodeFFAssets.ResourceBuilder(buildConfig,NodeFFAssets.FunctionFactory.Constructor.readFile());
var assetBuilderC = new NodeFFAssets.ResourceBuilder(buildConfig,NodeFFAssets.FunctionFactory.Constructor.readFileMinify());
var assetBuilderD = new NodeFFAssets.ResourceBuilder(buildConfig,NodeFFAssets.FunctionFactory.Constructor.readFileMinify(minifyOptions));
var assetBuilderE = new NodeFFAssets.ResourceBuilder(buildConfig,function(file,callback) {
// return file data to callback(err,data);
);
// Create events
assetBuilderA.on('begin', function() { });
assetBuilderA.on('end', function() { });
assetBuilderA.on('log', function(logLevel, logMessage) { });
assetBuilderA.on('error', function(err) { });
assetBuilderA.on('result', function(resultValue) { });
assetBuilderA.on('file-download-pre', function(remoteUrl) { });
assetBuilderA.on('file-download-post', function(localFile) { });
assetBuilderA.on('file-read-pre', function(localFile) { });
assetBuilderA.on('file-read-post', function(localFile) { });
assetBuilderA.on('file-write-pre', function(targetFile) { });
assetBuilderA.on('file-write-post', function(targetFile) { });
// Use build in event functions
assetBuilderB.on('log', NodeFFAssets.FunctionFactory.Event.log.console('css'));
assetBuilderB.on('result', NodeFFAssets.FunctionFactory.Event.result.objectSet(server,'includeCssFiles'));
// Run builder
assetBuilderC.run(function(err) {
//done
});
## Example simple
// note1: www_static/[js/css]/lib is versioned ingored.
// note2: server routes;
// app.use('/static',express.static(path.join(__dirname,'www_static')));
// app.use('/static/module/bootstrap',express.static(path.join(__dirname,'node_modules/bootstrap/dist')));
var NodeFFAssets = require('node-ff-assets');
var buildCss = new NodeFFAssets.ResourceBuilder({
linkMapping: {
'/static/module/bootstrap/': 'node_modules/bootstrap/dist/',
'/static/': 'www_static/',
},
linkTarget: '/static/css/lib/assets.css',
linkSources: [
'/static/module/bootstrap/css/bootstrap.css',
'/static/css/site.css',
],
});
buildCss.on('log', NodeFFAssets.FunctionFactory.Event.log.console('css'));
buildCss.on('result', NodeFFAssets.FunctionFactory.Event.result.objectSet(server,'includeCssFiles'));
buildCss.run(function(err) {
// done
})
## Tests
npm test (TODO)
## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style.
Add unit tests for any new or changed functionality. Lint and test your code.
## Release History
* 0.1.0 Initial release

View file

@ -1,7 +1,7 @@
{
"name": "node-ff-assets",
"version": "0.1.0",
"description": "Node.js library providing single resource assets.",
"description": "Site assets local/remote aggregation with minify.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
@ -9,6 +9,8 @@
"author": "Willem <willem.git.2015@forwardfire.net> (http://forwardfire.net/)",
"license": "BSD-2-Clause",
"dependencies": {
"fs-extra": "^0.16.3"
"fetch": "^0.3.6",
"fs-extra": "^0.16.3",
"minify": "^1.4.8"
}
}