forgeplus-react/scripts/concat.js

85 lines
2.8 KiB
JavaScript
Raw Normal View History

2020-03-16 14:12:11 +08:00
var fs = require('fs');
var uglify = require("uglify-js");
var path = require('path');
2020-04-28 17:23:34 +08:00
var concat = require('concat')
2020-03-16 14:12:11 +08:00
var results = [];
2020-04-28 17:23:34 +08:00
var walk = function (dir, done) {
fs.readdir(dir, function (err, list) {
console.log(list)
if (err) return done(err);
var pending = list.length;
if (!pending) return done(null, results);
list.forEach(function (file) {
file = path.resolve(dir, file);
fs.stat(file, function (err, stat) {
if (stat && stat.isDirectory()) {
walk(file, function (err, res) {
// results = results.concat(res);
if (!--pending) done(null, results);
});
} else {
results.push(file);
if (!--pending) done(null, results);
}
});
});
});
2020-03-16 14:12:11 +08:00
};
// 需要输出文件名数组时改为true
var jsDir = './public/js/';
var cssDir = './public/css'
// true &&
false &&
2020-04-28 17:23:34 +08:00
walk(cssDir, function () {
console.log('results', results.length, results)
})
2020-03-16 14:12:11 +08:00
// return;
// ----------------------------------------------------------------------------- CSS
2020-04-28 17:23:34 +08:00
var cssResults = [
'D:\\Code\\trustieplus\\public\\react\\public\\css\\edu-common.css',
'D:\\Code\\trustieplus\\public\\react\\public\\css\\edu-public.css',
'D:\\Code\\trustieplus\\public\\react\\public\\css\\taskstyle.css',
'D:\\Code\\trustieplus\\public\\react\\public\\css\\font-awesome.css',
'D:\\Code\\trustieplus\\public\\react\\public\\css\\editormd.min.css',
'D:\\Code\\trustieplus\\public\\react\\public\\css\\merge.css',
]
concat(cssResults, './public/css/css_min_all.css')
2020-03-16 14:12:11 +08:00
return;
// ----------------------------------------------------------------------------- JS
2020-04-28 17:23:34 +08:00
var _results = [
2020-03-16 14:12:11 +08:00
'D:\\Code\\trustieplus\\public\\react\\public\\js\\jquery-1.8.3.min.js',
'D:\\Code\\trustieplus\\public\\react\\public\\js\\editormd\\underscore.min.js',
'D:\\Code\\trustieplus\\public\\react\\public\\js\\editormd\\marked.min.js',
'D:\\Code\\trustieplus\\public\\react\\public\\js\\editormd\\prettify.min.js',
2020-04-28 17:23:34 +08:00
'D:\\Code\\trustieplus\\public\\react\\public\\js\\editormd\\raphael.min.js',
'D:\\Code\\trustieplus\\public\\react\\public\\js\\editormd\\sequence-diagram.min.js',
2020-03-16 14:12:11 +08:00
'D:\\Code\\trustieplus\\public\\react\\public\\js\\editormd\\flowchart.min.js',
2020-04-28 17:23:34 +08:00
'D:\\Code\\trustieplus\\public\\react\\public\\js\\editormd\\jquery.flowchart.min.js',
'D:\\Code\\trustieplus\\public\\react\\public\\js\\editormd\\editormd.min.js',
2020-03-16 14:12:11 +08:00
'D:\\Code\\trustieplus\\public\\react\\public\\js\\codemirror\\codemirror.js',
'D:\\Code\\trustieplus\\public\\react\\public\\js\\codemirror\\mode\\javascript.js',
'D:\\Code\\trustieplus\\public\\react\\public\\js\\diff_match_patch.js',
2020-04-28 17:23:34 +08:00
'D:\\Code\\trustieplus\\public\\react\\public\\js\\merge.js',
2020-03-16 14:12:11 +08:00
2020-04-28 17:23:34 +08:00
'D:\\Code\\trustieplus\\public\\react\\public\\js\\edu_tpi.js',
2020-03-16 14:12:11 +08:00
2020-04-28 17:23:34 +08:00
]
2020-03-16 14:12:11 +08:00
2020-04-28 17:23:34 +08:00
concat(_results, './public/js/js_min_all.js')