-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
45 lines (40 loc) · 1022 Bytes
/
.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
const eleventySass = require('eleventy-sass');
const htmlMinifier = require('html-minifier');
const inputDir = 'src';
const outputDir = 'dist';
module.exports = function(eleventyConfig) {
// Copy static files
eleventyConfig.addPassthroughCopy({
[`${inputDir}/_static`]: '/',
});
// Compile scss files
eleventyConfig.addPlugin(eleventySass, {
compileOptions: {
permalink: function(contents, inputPath) {
return (data) => data.page.filePathStem.replace(/^\/_scss\//, '/css/') + '.css';
}
},
sass: {
style: 'compressed',
sourceMap: false,
},
});
// Minify HTML
eleventyConfig.addTransform('htmlmin', function(content, outputPath) {
if (outputPath.endsWith('.html')) {
return htmlMinifier.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
});
} else {
return content;
}
});
return {
dir: {
input: inputDir,
output: outputDir,
},
};
}