diff --git a/lib/filter.js b/lib/filter.js index a66b3fc..27fb6e9 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -28,12 +28,18 @@ function logic_html(str, data) { var result = Htmlminifier(str, options); var saved = ((str.length - result.length) / str.length * 100).toFixed(2); log.log('neat the html: %s [ %s saved]', path, saved + '%'); + var now = new Date(); + // var prefix='"; + var end = ''; + result = prefix + result + end; return result; }; function logic_css(str, data) { var hexo = this, - options = hexo.config.neat_css; + options = hexo.config.neat_css; // Return if disabled. if (false === options.enable) return; @@ -46,13 +52,16 @@ function logic_css(str, data) { if (minimatch(path, exclude[i])) return str; } } - + var log = hexo.log || console.log; - return new Promise(function (resolve, reject) { - new CleanCSS(options).minify(str, function (err, result) { + return new Promise(function(resolve, reject) { + new CleanCSS(options).minify(str, function(err, result) { if (err) return reject(err); var saved = ((str.length - result.styles.length) / str.length * 100).toFixed(2); - resolve(result.styles); + var prefix = '/* build time:' + new Date().toLocaleString() + "*/\n"; + var end = '\n/* rebuild by neat */'; + var css_result = prefix + result.styles + end; + resolve(css_result); log.log('neat the css: %s [ %s saved]', path, saved + '%'); }); }); @@ -78,8 +87,10 @@ function logic_js(str, data) { var result = UglifyJS.minify(str, options); var saved = ((str.length - result.code.length) / str.length * 100).toFixed(2); log.log('neat the js: %s [ %s saved]', path, saved + '%'); - - return result.code; + var prefix = '// build time:' + new Date().toLocaleString() + "\n"; + var end = '\n//rebuild by neat '; + var js_result = prefix + result.code + end; + return js_result; } @@ -88,4 +99,4 @@ module.exports = { logic_html: logic_html, logic_css: logic_css, logic_js: logic_js, -}; \ No newline at end of file +}; diff --git a/package.json b/package.json index 4edd1c7..dfbd348 100644 --- a/package.json +++ b/package.json @@ -33,5 +33,5 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, - "version": "1.0.2" + "version": "1.0.3" }