-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.eleventy.js
31 lines (24 loc) · 873 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
const { readFileSync } = require('fs')
const { parse } = require('path')
const postcssrc = require('postcss-load-config')
const EngineCSS = require('./EngineCSS.js')
module.exports = (config) => {
const engine = new EngineCSS();
config.addTemplateFormats('css')
config.addExtension('css', {
outputFileExtension: 'css',
init: async function() {
engine.setInputDir(this.config.inputDir)
engine.setIncludesDir(this.config.dir.includes)
const {plugins, options} = await postcssrc()
engine.setPlugins(plugins)
engine.setOptions(options)
},
compile: function(input, inputPath) {
if (!input) throw new Error('No input')
const parsed = parse(inputPath)
if (parsed.name.startsWith('_')) return
return async ({page}) => engine.processCSS(input, {inputPath, outputPath: page.outputPath})
}
})
}