-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
36 lines (29 loc) · 957 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
const fs = require("fs");
// add browser prefixers and minify on a production build
processCSS = () => {
if (process.env.ELEVENTY_ENV === "production") {
const postcss = require("postcss");
const autoprefixer = require("autoprefixer");
const cssnano = require("cssnano");
const cssFileInput = "./src/css/style.css";
const cssFileOutput = "./public/css/style.css";
const css = fs.readFileSync(cssFileInput);
postcss([autoprefixer("last 10 versions", "ie 11"), cssnano])
.process(css, { from: cssFileInput })
.then((result) => {
fs.writeFileSync(cssFileOutput, result.css);
})
.catch((err) => console.log);
}
};
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("./src/css");
eleventyConfig.addPassthroughCopy("./src/images");
eleventyConfig.on("afterBuild", processCSS);
return {
dir: {
input: "src",
output: "public",
},
};
};