@epublishing/grunt-epublishing 0.3.13 → 0.3.15

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,13 +4,42 @@
4
4
 
5
5
  'use strict';
6
6
 
7
- const sass = require('sass');
8
- const NODE_ENV = process.env.NODE_ENV || 'development';
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
+ };
9
24
 
10
25
  module.exports = function configureSass(config) {
11
26
 
12
27
  config.sass.options.implementation = sass;
13
28
 
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
+
14
43
 
15
44
  return config;
16
45
  };
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.13",
4
+ "version": "0.3.15",
5
5
  "homepage": "https://www.epublishing.com",
6
6
  "contributors": [
7
7
  {
@@ -62,6 +62,7 @@
62
62
  "grunt-contrib-uglify": "^3.4.0",
63
63
  "grunt-contrib-watch": "^1.1.0",
64
64
  "grunt-postcss": "^0.9.0",
65
+ "grunt-sass": "^3.1.0",
65
66
  "grunt-webpack": "^3.1.2",
66
67
  "handlebars": "^4.0.11",
67
68
  "handlebars-loader": "^1.6.0",
package/tasks/sass.js DELETED
@@ -1,44 +0,0 @@
1
- 'use strict';
2
- var path = require('path');
3
- var eachAsync = require('each-async');
4
- var assign = require('object-assign');
5
- var sass = require('sass');
6
-
7
- module.exports = function (grunt) {
8
- grunt.verbose.writeln('\n' + sass.info + '\n');
9
-
10
- grunt.registerMultiTask('sass', 'Compile Sass to CSS', function () {
11
- eachAsync(this.files, function (el, i, next) {
12
- var opts = this.options({
13
- precision: 10
14
- });
15
-
16
- var src = el.src[0];
17
-
18
- if (!src || path.basename(src)[0] === '_') {
19
- next();
20
- return;
21
- }
22
-
23
- sass.render(assign({}, opts, {
24
- file: src,
25
- outFile: el.dest
26
- }), function (err, res) {
27
- if (err) {
28
- grunt.log.error(err.formatted + '\n');
29
- grunt.warn('');
30
- next(err);
31
- return;
32
- }
33
-
34
- grunt.file.write(el.dest, res.css);
35
-
36
- if (opts.sourceMap) {
37
- grunt.file.write(this.options.sourceMap, res.map);
38
- }
39
-
40
- next();
41
- });
42
- }.bind(this), this.async());
43
- });
44
- };