Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--serve is building files with previous layout, previous values, and inconsistent results. #3546

Open
bye-csavier opened this issue Nov 20, 2024 · 0 comments

Comments

@bye-csavier
Copy link

bye-csavier commented Nov 20, 2024

Operating system

Windows 10 22H2

Eleventy

v3.0.0

Describe the bug

I registered a video (sorry, it's lengthy) to show the behavior because it's a bit complex to explain it.
By using npx @11ty/eleventy --incremental, the output is consistent and matches expectations.

Reproduction steps

eleventy.config.js

import * as sass from 'sass';
import { minify as minifyCSS } from './src/res/js/libs/csso.js';

export default async function(config){

    config.setInputDirectory("src");
    config.setOutputDirectory("dist");

    config.addWatchTarget("src/**/*");

    config.setQuietMode(true);

    config.addPassthroughCopy("src/assets");
    config.addPassthroughCopy("src/**/*.html");
	config.addPassthroughCopy("src/res/js/**/*.js");

	config.addTemplateFormats("scss");
	config.addExtension("scss", {
		outputFileExtension:"css",
		compile: async function (inputContent, inputPath) {
			let result = sass.compileString(inputContent);
			this.addDependencies(inputPath, result.loadedUrls);
			result = minifyCSS(result.css)
			return async () => {
				return result.css;
			};
		},
	});
	
};

src/_layout/index.njk

<!DOCTYPE html>
<html lang="en">
<head>

   <!-- code -->

    <style>{{ patchCssPreviewCss | safe }}</style>

</head>
<body>
   <!-- code -->
    <main>
        {{ content | safe }}
    </main>

</body>
</html>

src/index.11ty.js

//code

export const data = {
	layout: "index.njk",
};

export function render(data) {
    //code
    data.patchCssPreviewCss = minifyCSS(innerStyles).css;
    return content;
};

I omitted code I think is irrelevant to the issue, if it's required to replicate I'll provide it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant