@epublishing/grunt-epublishing 0.3.16 → 0.3.18
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/lib/init-jade-config.js +0 -4
- package/package.json +1 -4
- package/tasks/sass.js +44 -0
- package/lib/configure-sass.js +0 -45
package/lib/init-jade-config.js
CHANGED
|
@@ -11,7 +11,6 @@ const fs = require('fs');
|
|
|
11
11
|
const prettyjson = require('prettyjson');
|
|
12
12
|
const mergeConfigs = require('./merge-configs');
|
|
13
13
|
const configureWebpack = require('./configure-webpack');
|
|
14
|
-
const configureSass = require('./configure-sass');
|
|
15
14
|
const configurePostCSS = require('./configure-postcss');
|
|
16
15
|
|
|
17
16
|
module.exports = function initJadeConfig(grunt, jadePath, jadeChildPath, jadeChildPaths) {
|
|
@@ -40,9 +39,6 @@ module.exports = function initJadeConfig(grunt, jadePath, jadeChildPath, jadeChi
|
|
|
40
39
|
// Update baseConfig's Webpack settings with ePublishing defaults:
|
|
41
40
|
baseConfig = configureWebpack(grunt, baseConfig);
|
|
42
41
|
|
|
43
|
-
// Add custom functions and settings to the merged Sass config
|
|
44
|
-
baseConfig = configureSass(baseConfig);
|
|
45
|
-
|
|
46
42
|
if (baseConfig.postcss) {
|
|
47
43
|
baseConfig = configurePostCSS(baseConfig, grunt);
|
|
48
44
|
}
|
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.18",
|
|
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,44 @@
|
|
|
1
|
+
/* eslint-disable prefer-object-spread, promise/prefer-await-to-then */
|
|
2
|
+
'use strict';
|
|
3
|
+
const util = require('util');
|
|
4
|
+
const sass = require('sass');
|
|
5
|
+
const path = require('path');
|
|
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(sass.render)(Object.assign({}, options, {
|
|
29
|
+
file: src,
|
|
30
|
+
outFile: item.dest,
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
grunt.file.write(item.dest, result.css);
|
|
34
|
+
|
|
35
|
+
if (options.sourceMap) {
|
|
36
|
+
const filePath = options.sourceMap === true ? `${item.dest}.map` : options.sourceMap;
|
|
37
|
+
grunt.file.write(filePath, result.map);
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
})().catch(error => {
|
|
41
|
+
grunt.fatal(error.formatted || error);
|
|
42
|
+
}).then(done);
|
|
43
|
+
});
|
|
44
|
+
};
|
package/lib/configure-sass.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This function merges custom SassScript functions into the base Sass config
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
'use strict';
|
|
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
|
-
};
|
|
24
|
-
|
|
25
|
-
module.exports = function configureSass(config) {
|
|
26
|
-
|
|
27
|
-
config.sass.options.implementation = sass;
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
return config;
|
|
45
|
-
};
|