modify tools 👍
This commit is contained in:
parent
f9bb8cf4e0
commit
fd2b7c20e9
23
toolers/Gulpfile.js
Normal file
23
toolers/Gulpfile.js
Normal file
@ -0,0 +1,23 @@
|
||||
var gulp = require ('gulp'),
|
||||
minifycss = require('gulp-minify-css'),
|
||||
rename = require('gulp-rename'),
|
||||
uglify = require ('gulp-uglify'),
|
||||
clean = require('gulp-clean');
|
||||
|
||||
gulp.task ('clean', function () {
|
||||
gulp.src('../*/css/*.min.css').pipe(clean({force: true}));
|
||||
|
||||
gulp.src('../*/js/*.min.js').pipe(clean({force: true}));
|
||||
});
|
||||
|
||||
gulp.task ('build', function () {
|
||||
gulp.src ('../*/css/*.css')
|
||||
.pipe(rename({ suffix: '.min' }))
|
||||
.pipe(minifycss())
|
||||
.pipe(gulp.dest ('../'));
|
||||
|
||||
gulp.src ('../*/js/*.js')
|
||||
.pipe(rename({ suffix: '.min' }))
|
||||
.pipe(uglify())
|
||||
.pipe(gulp.dest ('../'));
|
||||
});
|
@ -1,55 +0,0 @@
|
||||
var fs = require("fs"),
|
||||
path = require('path'),
|
||||
exec = require("child_process").exec;
|
||||
|
||||
var getCompressFiles = function (root) {
|
||||
var res = [],
|
||||
files = fs.readdirSync(root);
|
||||
|
||||
files.forEach(function(file) {
|
||||
var pathname = root + '/' + file,
|
||||
stat = fs.lstatSync(pathname);
|
||||
|
||||
if (!stat.isDirectory()) {
|
||||
if (pathname.indexOf("mobile") < 0 && path.basename(pathname).indexOf(".min") < 0) {
|
||||
if (path.dirname(pathname).indexOf("css") > -1 && path.extname(pathname) === ".css") {
|
||||
res.push("css-" + pathname);
|
||||
}
|
||||
|
||||
if (path.dirname(pathname).indexOf("js") > -1 && path.extname(pathname) === ".js") {
|
||||
res.push("js-" + pathname);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res = res.concat(getCompressFiles(pathname));
|
||||
}
|
||||
});
|
||||
return res;
|
||||
};
|
||||
|
||||
(function () {
|
||||
var compressFiles = getCompressFiles("..");
|
||||
|
||||
for (var i = 0; i < compressFiles.length; i++) {
|
||||
// skin js compress
|
||||
if (compressFiles[i].indexOf("js-") > -1) {
|
||||
var pathname = compressFiles[i].split("js-")[1];
|
||||
console.log("compress js:" + pathname);
|
||||
exec("uglifyjs " + pathname + " > " + path.dirname(pathname) + "/" + path.basename(pathname, ".js") + ".min.js", function (error, stdout, stderr) {
|
||||
if (error !== null) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
// skin css compress
|
||||
if (compressFiles[i].indexOf("css-") > -1) {
|
||||
var pathname = compressFiles[i].split("css-")[1];
|
||||
console.log("compress css:" + pathname);
|
||||
exec("lessc -compress " + pathname + " > " + path.dirname(pathname) + "/" + path.basename(pathname, ".css") + ".min.css", function (error, stdout, stderr) {
|
||||
if (error !== null) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
Loading…
x
Reference in New Issue
Block a user