-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
52 lines (48 loc) · 1.29 KB
/
.eleventy.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
42
43
44
45
46
47
48
49
50
51
52
const { minify } = require("uglify-js");
const sass = require("sass");
const path = require("node:path");
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy('src/font');
eleventyConfig.addPassthroughCopy('src/img');
eleventyConfig.addPassthroughCopy('src/*.txt');
eleventyConfig.addPassthroughCopy('src/*.ico');
eleventyConfig.addTemplateFormats("js");
eleventyConfig.addExtension("js", {
outputFileExtension: "js",
compile: async function(inputContent) {
const result = minify(inputContent);
return async () => {
return result.code;
};
}
});
eleventyConfig.addTemplateFormats("scss");
eleventyConfig.addExtension("scss", {
outputFileExtension: "css",
compile: async function(inputContent, inputPath) {
let parsed = path.parse(inputPath);
if(parsed.name.startsWith("_")) {
return async () => {
return;
};
}
let result = sass.compileString(inputContent, {
style: 'compressed',
loadPaths: [
parsed.dir || ".",
'node_modules/normalize.css',
this.config.dir.includes
]
});
return async () => {
return result.css;
};
}
});
return {
dir: {
input: 'src',
output: 'dist'
}
}
};