cssnano task implemented

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 8 years ago
parent 97bb6f3a33
commit 4bf34bf668
  1. 35
      BuildServer/lib/tasks/cssnano.js
  2. 36
      BuildServer/lib/tasks/cssnanoall.js
  3. 3
      BuildServer/lib/tasks/packform.js
  4. 1
      BuildServer/package.json

@ -0,0 +1,35 @@
"use strict";
const fs = require('fs');
const path = require('path');
const cssnano = require("cssnano");
module.exports = (params, processor) => ({
process: () => {
const filePath = path.normalize(processor.context.exported + "/" + params.filename);
fs.readFile(filePath, (err, css) => {
if (err) {
processor.onError("Unable to read stylesheet " + params.filename + ": " + err);
return processor.done();
}
cssnano.process(css)
.catch((err) => {
processor.onError("Unable to uglify stylesheet: " + err);
processor.done();
})
.then((result) => {
fs.writeFile(filePath, result.css, (err) => {
if (err) {
processor.onError("Unable to write uglified stylesheet for " + params.filename + ": " + err);
} else {
processor.onInfo("Saved uglified stylesheet for " + params.filename + "; uglified length: " + result.css.length);
}
processor.done();
});
});
});
}
});

@ -0,0 +1,36 @@
"use strict";
const glob = require('glob');
module.exports = (params, processor) => ({
process: () => {
if (processor.context.cssnanoallDone) {
processor.onWarn("cssnanoall task is executed more than once; this is probably a bug in your mbs.json");
}
processor.context.cssnanoallDone = true;
glob("**/*.css", {
dot: true,
cwd: processor.context.exported
}, (err, files) => {
if (err) {
processor.onError(err);
return processor.done();
}
return processor.processTask({
type: params.preventParallelTests ? "sequential" : "parallel",
params: {
tasks: files.map((file) => ({
name: file,
type: "cssnano",
params: {
filename: file
}
}))
}
}, processor.done.bind(processor));
});
}
});

@ -7,6 +7,9 @@ module.exports = (params, processor) => sequential({
{ {
type: "uglifyjsall" type: "uglifyjsall"
}, },
{
type: "cssnanoall"
},
{ {
type: "zip", type: "zip",
params: { params: {

@ -9,6 +9,7 @@
"adm-zip": "0.4.7", "adm-zip": "0.4.7",
"async": "~2.1.4", "async": "~2.1.4",
"body-parser": "^1.15.2", "body-parser": "^1.15.2",
"cssnano": "^3.9.1",
"express": "4.14.0", "express": "4.14.0",
"fs-extra": "^1.0.0", "fs-extra": "^1.0.0",
"github": "~7.1.0", "github": "~7.1.0",

Loading…
Cancel
Save