-
Notifications
You must be signed in to change notification settings - Fork 6
/
templateLanguages.js
41 lines (37 loc) · 982 Bytes
/
templateLanguages.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Add Eleventy template languages here
* https://www.11ty.dev/docs/languages/custom/
*/
module.exports = {
/**
* Compile Sass/scss files to CSS using Sass
*/
scss: function () {
// Require dependencies
let path = require("path");
let sass = require("sass");
let config = {
// Set the output file extension
outputFileExtension: "css",
// Compile should return a string
compile: function (contents, inputPath) {
let parsed = path.parse(inputPath);
if(parsed.name.startsWith("_")) {
return;
}
let includesPaths = [this.config.dir.includes];
return (data) => {
let result = sass.renderSync({
file: inputPath,
includesPaths,
data: contents,
outputStyle: "compressed",
});
return result.css.toString("utf8");
};
}
}
// Return the config to .eleventy.js
return config;
}
}