11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
17.32k stars 495 forks source link

--incremental not having any effect? #2053

Closed alvarotrigo closed 1 year ago

alvarotrigo commented 3 years ago

I'm using this on my package.json

{
  "name": "blog-11ty",
  "version": "1.0.0",
  "description": "",
  "main": ".eleventy.js",
  "scripts": {
    "serve": "npx @11ty/eleventy --serve",
    "build": "npx @11ty/eleventy --incremental"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@quasibit/eleventy-plugin-schema": "^1.0.0"
  },
  "devDependencies": {
    "@11ty/eleventy": "^0.12.1",
    "@11ty/eleventy-img": "^0.8.3",
    "@11ty/eleventy-plugin-rss": "^1.1.0",
    "@11ty/eleventy-plugin-syntaxhighlight": "^3.0.6",
    "glob": "^7.2.0",
    "gulp-exec": "^5.0.0",
    "markdown-it": "^12.2.0",
    "markdown-it-anchor": "^8.4.1",
    "markdown-it-link-attributes": "^3.0.0"
  }
}

This is my current .eleventy.js stripped off, the one I'm using to test this:

const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const pluginRss = require("@11ty/eleventy-plugin-rss");

async function imageShortcode(src, alt, width, height) {
    return '';
}

async function codepenShortcode(url, tab) {
    return '';
}

async function buttonShortCode(url, text) {
    return '';
}

async function videoShortCode(url) {
    return '';
}

module.exports = function(eleventyConfig) {

    eleventyConfig.addPlugin(syntaxHighlight);
    eleventyConfig.addPlugin(pluginRss);

    // Turn off filename quoting in include tags
    eleventyConfig.setLiquidOptions({
        dynamicPartials: false
    });

    eleventyConfig.addCollection('posts', 
    collection => collection.getFilteredByGlob('blog/*.md').sort((a, b) => b.date - a.date));

    eleventyConfig.addLayoutAlias('category', 'layouts/category.html');

    eleventyConfig.addLayoutAlias('default', 'layouts/default.html');

    eleventyConfig.addLayoutAlias('home', 'layouts/home.html');

    eleventyConfig.addLayoutAlias('page', 'layouts/page.html');

    eleventyConfig.addLayoutAlias('post', 'layouts/post.html');

    eleventyConfig.addLiquidShortcode("image", imageShortcode);
    eleventyConfig.addLiquidShortcode("codepen", codepenShortcode);
    eleventyConfig.addLiquidShortcode("video", videoShortCode);
    eleventyConfig.addLiquidShortcode("button", buttonShortCode);

    return {
        dir: {
            input: './',
            output: './_site'
        },
        passthroughFileCopy: true
    };
};

Now, every time I run npm run build every single file inside the output folder (_site) gets modified. The modification time of each file changes.

Am I missing something?

I would expect the files to only be modified the the source file modification date changed too?

AleksandrHovhannisyan commented 3 years ago

I believe the --incremental flag is only intended for development, not production builds. When used in conjunction with serve, the local server will only rebuild files/templates that changed and skip the rest. I may be mistaken, though.

alvarotrigo commented 2 years ago

Any update on this?

I'd be nice to only update those files that need to be updated.

In my case, I'm using rsync to upload the new/modified files to the server and right now every time I change a single post, all the blog is uploaded again...

AleksandrHovhannisyan commented 2 years ago

@alvarotrigo Are you hosting your site on Netlify? If so, netlify-plugin-11ty allows you to cache folders. You might not be able to cache posts, though. I don't believe there's currently a way to do this on the 11ty end; incremental builds are a dev-only thing.

alvarotrigo commented 2 years ago

Nope. My own host.

zachleat commented 1 year ago

I think there are a few misunderstandings here, probably chiefly noted by @sentience at https://github.com/11ty/eleventy/issues/2760

That said, --incremental is currently limited to local dev and runs a full build initially. You can use the 2.0 flag for --ignore-initial to bypass this!

Docs: https://www.11ty.dev/docs/usage/#incremental-for-partial-incremental-builds

More info at: https://www.11ty.dev/docs/usage/incremental/

Running incremental builds on a build server is filed at https://github.com/11ty/eleventy/issues/2775