nodeclub/bin/combo
2013-06-19 02:40:02 +08:00

28 lines
841 B
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
"use strict";
var path = require('path');
var fs = require('fs');
var Loader = require('loader');
// app/views
var viewsDir = path.join(process.cwd(), process.argv[2]);
// app/
var baseDir = path.join(process.cwd(), process.argv[3]);
// scan views folder, get the assets map
var scaned = Loader.scanDir(viewsDir);
console.log("Scaned:");
console.log(scaned);
// need minify?
var justCombo = process.argv[4];
// combomd5 hash
var minified = Loader.minify(baseDir, scaned, justCombo);
console.log(minified);
console.log("Compile static assets done.");
// write the assets mapping into assets.json
fs.writeFileSync(path.join(baseDir, 'assets.json'), JSON.stringify(Loader.map(minified)));
console.log("write assets.json done. assets.json: ");
console.log(fs.readFileSync(path.join(baseDir, 'assets.json'), 'utf-8'));