forked from roadmapsh/deprecated-version
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
64 lines (52 loc) · 2.08 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
53
54
55
56
57
58
59
60
61
62
63
64
const fs = require('fs');
const path = require('path');
const esbuild = require('esbuild');
const { exec } = require('child_process');
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
const markdown = require('./config/utils/markdown');
const htmlmin = require('./config/transforms/htmlmin');
const sortedRoadmaps = require('./config/collections/sorted-roadmaps');
module.exports = function (eleventyConfig) {
eleventyConfig.setUseGitIgnore(false);
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addWatchTarget('./src/styles/main.css');
eleventyConfig.addWatchTarget('./src/scripts/');
eleventyConfig.ignores.add('./src/roadmaps/**/content');
// To be copied as it is
eleventyConfig
.addPassthroughCopy('./src/assets')
.addPassthroughCopy('./src/CNAME')
.addPassthroughCopy('./src/.nojekyll');
eleventyConfig.setServerPassthroughCopyBehavior('copy');
eleventyConfig.addCollection('allRoadmaps', sortedRoadmaps('roadmap'));
eleventyConfig.addCollection('skillRoadmaps', sortedRoadmaps('skill-roadmap'));
eleventyConfig.addCollection('roleRoadmaps', sortedRoadmaps('role-roadmap'));
// Only add the htmlmin transform if we are not in dev mode
if (process.env.NODE_ENV === 'production') {
eleventyConfig.addTransform('htmlmin', htmlmin);
}
// Custom markdown library
eleventyConfig.setLibrary('md', markdown);
// Rebuild tailwind before reloading
eleventyConfig.on('eleventy.after', async () => {
console.log('Building Tailwind…');
exec('npm run build:tailwind').toString();
console.log('Bundling JavaScript files');
const scriptsDir = path.join(__dirname, './src/scripts/');
return esbuild.build({
entryPoints: fs.readdirSync(scriptsDir).map((scriptName) => path.join(scriptsDir, scriptName)),
entryNames: '[dir]/[name]',
outdir: path.join(__dirname, '_site', 'scripts'),
bundle: true,
minify: true,
sourcemap: process.env.ELEVENTY_ENV !== 'production',
});
});
return {
htmlTemplateEngine: 'njk',
dir: {
input: 'src',
output: '_site',
},
};
};