@epublishing/grunt-epublishing 0.3.6 → 0.3.8

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.
@@ -9,11 +9,12 @@ const NODE_ENV = process.env.NODE_ENV || 'development';
9
9
 
10
10
  module.exports = function configureSass(config) {
11
11
 
12
- config.sass.options.implementation = sass;
13
12
 
14
- config.sass.options.functions = {
15
- 'epub-node-env()': () => new sass.String(NODE_ENV),
13
+ return {
14
+ sass: {
15
+ options: {
16
+ implementation: sass,
17
+ }
18
+ }
16
19
  };
17
-
18
- return config;
19
20
  };
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.6",
4
+ "version": "0.3.8",
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/jade.js CHANGED
@@ -14,19 +14,11 @@ const initJadeConfig = require('../lib/init-jade-config');
14
14
  module.exports = function(grunt) {
15
15
  grunt.option('siteRoot', process.cwd())
16
16
 
17
- console.log('~~~~~~~~~~~~~~~~~~~~')
18
- console.log('~~~~~~~DEBUG~~~~~~~~')
19
- console.log('~~~~~~~~~~~~~~~~~~~~')
20
-
21
-
22
17
  if (!grunt.option('no-time')) timeGrunt(grunt);
23
-
24
18
  jitGrunt(grunt, {
25
19
  'install-eslint': '@epublishing/grunt-install-eslint',
26
20
  });
27
21
 
28
-
29
-
30
22
  /**
31
23
  * This registers a grunt task which shells out and uses bundler to
32
24
  * determine the paths to the jade gem and any jade child engine gem
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
+ };