@epublishing/grunt-epublishing 0.3.16 → 0.3.17

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.
@@ -4,42 +4,13 @@
4
4
 
5
5
  'use strict';
6
6
 
7
- const sass = require('sass');
8
- const path = require('path');
9
-
10
- const sassAliases = {
11
- '^compass': function (url) {
12
- return path.join(
13
- process.cwd(),
14
- 'node_modules',
15
- 'compass-mixins',
16
- 'lib',
17
- url
18
- );
19
- },
20
- '^bourbon$': 'bourbon/app/assets/stylesheets/bourbon',
21
- '^breakpoint$': 'breakpoint-sass/stylesheets/breakpoint',
22
- '^susyone$': 'susy/sass/susyone'
23
- };
7
+ const sass = require('sass');
8
+ const NODE_ENV = process.env.NODE_ENV || 'development';
24
9
 
25
10
  module.exports = function configureSass(config) {
26
11
 
27
12
  config.sass.options.implementation = sass;
28
13
 
29
- config.sass.options.importer = (url, prev, done) => {
30
- for (const key in sassAliases) {
31
- const pattern = new RegExp(key);
32
- const alias = sassAliases[key];
33
-
34
- if (pattern.test(url)) {
35
- const value = alias instanceof Function ? alias(url) : alias;
36
- return done({ file: value });
37
- }
38
- }
39
-
40
- return done({ file: url });
41
- }
42
-
43
14
 
44
15
  return config;
45
16
  };
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.16",
4
+ "version": "0.3.17",
5
5
  "homepage": "https://www.epublishing.com",
6
6
  "contributors": [
7
7
  {
@@ -40,7 +40,6 @@
40
40
  "compression-webpack-plugin": "^1.1.7",
41
41
  "css-loader": "^0.28.9",
42
42
  "cssnano": "^4.0.5",
43
- "each-async": "^2.0.0",
44
43
  "es5-shim": "^4.5.10",
45
44
  "es6-promise": "^4.2.4",
46
45
  "eslint": "^4.2.0",
@@ -62,7 +61,6 @@
62
61
  "grunt-contrib-uglify": "^3.4.0",
63
62
  "grunt-contrib-watch": "^1.1.0",
64
63
  "grunt-postcss": "^0.9.0",
65
- "grunt-sass": "^3.1.0",
66
64
  "grunt-webpack": "^3.1.2",
67
65
  "handlebars": "^4.0.11",
68
66
  "handlebars-loader": "^1.6.0",
@@ -70,7 +68,6 @@
70
68
  "jit-grunt": "^0.10.0",
71
69
  "listr": "^0.14.1",
72
70
  "lodash": "^4.17.10",
73
- "object-assign": "^4.1.1",
74
71
  "postcss-css-variables": "^0.9.0",
75
72
  "prettyjson": "^1.2.1",
76
73
  "read-pkg": "^4.0.1",
package/tasks/sass.js ADDED
@@ -0,0 +1,54 @@
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
+ const {pathToFileURL} = require('url');
6
+
7
+ module.exports = grunt => {
8
+ grunt.registerMultiTask('sass', 'Compile Sass to CSS', function () {
9
+ const done = this.async();
10
+
11
+ const options = this.options({
12
+ precision: 10
13
+ });
14
+
15
+ if (!options.implementation) {
16
+ grunt.fatal('The implementation option must be passed to the Sass task');
17
+ }
18
+ grunt.verbose.writeln(`\n${options.implementation.info}\n`);
19
+
20
+ (async () => {
21
+ await Promise.all(this.files.map(async item => {
22
+ const [src] = item.src;
23
+
24
+ if (!src || path.basename(src)[0] === '_') {
25
+ return;
26
+ }
27
+
28
+ const result = await util.promisify(options.implementation.compile)(Object.assign({}, options, {
29
+ file: src,
30
+ outFile: item.dest,
31
+ importers: [{
32
+ // An importer that redirects relative URLs starting with "~" to
33
+ // `node_modules`.
34
+ findFileUrl(url) {
35
+ console.log(url);
36
+
37
+ if (!url.startsWith('~')) return null;
38
+ return new URL(url.substring(1), pathToFileURL('node_modules'));
39
+ }
40
+ }]
41
+ }));
42
+
43
+ grunt.file.write(item.dest, result.css);
44
+
45
+ if (options.sourceMap) {
46
+ const filePath = options.sourceMap === true ? `${item.dest}.map` : options.sourceMap;
47
+ grunt.file.write(filePath, result.map);
48
+ }
49
+ }));
50
+ })().catch(error => {
51
+ grunt.fatal(error.formatted || error);
52
+ }).then(done);
53
+ });
54
+ };