Remove css & scss from templating languages
This commit is contained in:
parent
f5bebc057e
commit
9093d47677
|
|
@ -31,75 +31,6 @@ export default async function (eleventyConfig) {
|
|||
|
||||
eleventyConfig.addPassthroughCopy('src/favicon.ico')
|
||||
|
||||
// Recognize CSS as a "template language"
|
||||
eleventyConfig.addTemplateFormats("css");
|
||||
|
||||
// Process CSS with LightningCSS
|
||||
eleventyConfig.addExtension("css", {
|
||||
outputFileExtension: "css",
|
||||
compile: async function (_inputContent, inputPath) {
|
||||
let parsed = path.parse(inputPath);
|
||||
if (parsed.name.startsWith("_")) {
|
||||
return;
|
||||
}
|
||||
|
||||
let targets = browserslistToTargets(browserslist("> 0.2% and not dead"));
|
||||
|
||||
return async () => {
|
||||
// Switch to the `transform` function if you don't
|
||||
// plan to use `@import` to merge files
|
||||
let { code } = await bundle({
|
||||
filename: inputPath,
|
||||
minify: true,
|
||||
sourceMap: false,
|
||||
targets,
|
||||
// Supports CSS nesting
|
||||
drafts: {
|
||||
nesting,
|
||||
},
|
||||
});
|
||||
return code;
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// Recognize Sass as a "template languages"
|
||||
eleventyConfig.addTemplateFormats("scss");
|
||||
|
||||
// Compile Sass
|
||||
eleventyConfig.addExtension("scss", {
|
||||
outputFileExtension: "css",
|
||||
compile: async function (inputContent, inputPath) {
|
||||
// Skip files like _fileName.scss
|
||||
let parsed = path.parse(inputPath);
|
||||
if (parsed.name.startsWith("_")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Run file content through Sass
|
||||
let result = sass.compileString(inputContent, {
|
||||
loadPaths: [parsed.dir || "."],
|
||||
sourceMap: false, // or true, your choice!
|
||||
});
|
||||
|
||||
// Allow included files from @use or @import to
|
||||
// trigger rebuilds when using --incremental
|
||||
this.addDependencies(inputPath, result.loadedUrls);
|
||||
|
||||
let targets = browserslistToTargets(browserslist("> 0.2% and not dead"));
|
||||
|
||||
return async () => {
|
||||
let { code } = await transform({
|
||||
code: Buffer.from(result.css),
|
||||
minify: true,
|
||||
sourceMap: false,
|
||||
targets,
|
||||
});
|
||||
return code;
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
markdownTemplateEngine: 'liquid',
|
||||
dataTemplateEngine: 'liquid',
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"eleventyExcludeFromCollections": true
|
||||
}
|
||||
Loading…
Reference in a new issue