-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.js
87 lines (72 loc) · 2.09 KB
/
eleventy.config.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const postcss = require("postcss");
const postcssImport = require("postcss-import");
const postcssMediaMinmax = require("postcss-media-minmax");
const autoprefixer = require("autoprefixer");
const postcssCsso = require("postcss-csso");
const sass = require("sass");
const esbuild = require('esbuild');
const tailwindcss = require('tailwindcss');
const nesting = require('tailwindcss/nesting');
const pluginWebc = require('@11ty/eleventy-plugin-webc');
/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
module.exports = (eleventyConfig) => {
eleventyConfig.addShortcode("year", () => {
return `${new Date().getFullYear()}`;
});
eleventyConfig.setBrowserSyncConfig({
files: "./dist/styles/**/*.css",
});
eleventyConfig.setBrowserSyncConfig({
files: "./dist/scripts/**/*.js",
});
eleventyConfig.addPlugin(pluginWebc);
eleventyConfig.addWatchTarget("./src/styles/");
eleventyConfig.addPassthroughCopy("src/assets");
eleventyConfig.addTemplateFormats("css");
eleventyConfig.addExtension("css", {
outputFileExtension: "css",
compile: async (content, path) => {
console.log('path', path);
if (path !== "./src/styles/index.css") {
return;
}
return async () => {
let output = await postcss([
postcssImport,
nesting,
tailwindcss,
postcssMediaMinmax,
autoprefixer,
postcssCsso,
]).process(content, { from: path });
return output.css;
};
},
});
eleventyConfig.addTemplateFormats("js");
eleventyConfig.addExtension("js", {
outputFileExtension: "js",
compile: async (content, path) => {
if (path !== "./src/scripts/index.js") {
return;
}
return async () => {
let output = await esbuild.build({
target: 'es2020',
entryPoints: [path],
minify: true,
bundle: true,
write: false
});
return output.outputFiles[0].text;
};
},
});
return {
dir: {
input: "src",
output: "dist",
includes: "_includes",
},
};
};