forked from cnodejs/nodeclub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombo
executable file
·27 lines (23 loc) · 841 Bytes
/
combo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/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];
// combo?md5 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'));