11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.

Home Page:https://www.11ty.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

--incremental not having any effect?

alvarotrigo opened this issue · comments

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?

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.

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...

@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.

Nope. My own host.

I think there are a few misunderstandings here, probably chiefly noted by @sentience at #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 #2775