-
Notifications
You must be signed in to change notification settings - Fork 8
/
.eleventy.js
33 lines (31 loc) · 1.53 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
const prettier = require('prettier');
// this file configures how eleventy should behave when run with CLI
module.exports = eleventyConfig => {
// this adds a transform that will automatically run prettier on the HTML files that eleventy
// generates. resolveConfig will find the .prettierrc.json, then prettier will format it
eleventyConfig.addTransform('prettier', (content, outputPath) => {
return prettier.resolveConfig(outputPath).then(options => {
return prettier.format(content, {
...options,
});
});
});
// these passthroughcopy configurations will directly copy the files from the site/ folder
// to the output _site folder. assets/ is the css and javascript that should run on the static
// site, and docs/ is the auto-generated documentation that JSDoc makes and copies in
// (run `npm run docs` to generate it)
eleventyConfig.addPassthroughCopy('site/assets');
eleventyConfig.addPassthroughCopy('site/docs');
// this makes sure that any changes to the javascript files in the examples/ directory
// will trigger a re-build
eleventyConfig.addWatchTarget('site/examples/');
return {
// when distributed on github, all URLs need to be prefixed with /chs-js-lib/. this
// environment variable is set in the GitHub action workflow `pages-build-and-publish`
pathPrefix: process.env.GITHUB_ACTION ? '/chs-js-lib/' : '/_site/',
dir: {
input: 'site',
output: '_site',
},
};
};