@epublishing/grunt-epublishing 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -2
- package/tasks/sass.js +43 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epublishing/grunt-epublishing",
|
|
3
3
|
"description": "Automated front-end tasks for ePublishing Jade and client sites.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.7",
|
|
5
5
|
"homepage": "https://www.epublishing.com",
|
|
6
6
|
"contributors": [
|
|
7
7
|
{
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
"grunt-bower-install-simple": "^1.2.6",
|
|
59
59
|
"grunt-contrib-clean": "^1.1.0",
|
|
60
60
|
"grunt-contrib-concat": "^1.0.1",
|
|
61
|
-
"grunt-contrib-sass": "^2.0.0",
|
|
62
61
|
"grunt-contrib-uglify": "^3.4.0",
|
|
63
62
|
"grunt-contrib-watch": "^1.1.0",
|
|
64
63
|
"grunt-postcss": "^0.9.0",
|
package/tasks/sass.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* eslint-disable prefer-object-spread, promise/prefer-await-to-then */
|
|
2
|
+
'use strict';
|
|
3
|
+
const util = require('util');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
module.exports = grunt => {
|
|
7
|
+
grunt.registerMultiTask('sass', 'Compile Sass to CSS', function () {
|
|
8
|
+
const done = this.async();
|
|
9
|
+
|
|
10
|
+
const options = this.options({
|
|
11
|
+
precision: 10
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
if (!options.implementation) {
|
|
15
|
+
grunt.fatal('The implementation option must be passed to the Sass task');
|
|
16
|
+
}
|
|
17
|
+
grunt.verbose.writeln(`\n${options.implementation.info}\n`);
|
|
18
|
+
|
|
19
|
+
(async () => {
|
|
20
|
+
await Promise.all(this.files.map(async item => {
|
|
21
|
+
const [src] = item.src;
|
|
22
|
+
|
|
23
|
+
if (!src || path.basename(src)[0] === '_') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const result = await util.promisify(options.implementation.render)(Object.assign({}, options, {
|
|
28
|
+
file: src,
|
|
29
|
+
outFile: item.dest
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
grunt.file.write(item.dest, result.css);
|
|
33
|
+
|
|
34
|
+
if (options.sourceMap) {
|
|
35
|
+
const filePath = options.sourceMap === true ? `${item.dest}.map` : options.sourceMap;
|
|
36
|
+
grunt.file.write(filePath, result.map);
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
})().catch(error => {
|
|
40
|
+
grunt.fatal(error.formatted || error);
|
|
41
|
+
}).then(done);
|
|
42
|
+
});
|
|
43
|
+
};
|