11ty: --incremental 没有任何效果?
11ty: --incremental not having any effect?
我正在 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"
}
}
这是我当前的 .eleventy.js
剥离的,我用来测试的那个:
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
};
};
现在,每次我 运行 npm run build
输出文件夹 (_site
) 中的每个文件都会被修改。每个文件的修改时间变化。
我是不是漏掉了什么?
我希望文件只在源文件修改日期也改变的情况下被修改吗?
我认为增量只能与服务一起使用。文档说:
“增量构建仅对已更改的文件执行部分构建操作,以在进行本地开发时缩短构建时间。”
在我的测试中,我证实了这一点。我 运行 eleventy --incremental --serve
并注意到当我更改它时它一次只会重建一个文件。如果你 运行 它自己,它每次都会创建一个完整的构建,如此处记录:https://www.11ty.dev/docs/usage/incremental/#cold-start
我正在 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"
}
}
这是我当前的 .eleventy.js
剥离的,我用来测试的那个:
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
};
};
现在,每次我 运行 npm run build
输出文件夹 (_site
) 中的每个文件都会被修改。每个文件的修改时间变化。
我是不是漏掉了什么?
我希望文件只在源文件修改日期也改变的情况下被修改吗?
我认为增量只能与服务一起使用。文档说:
“增量构建仅对已更改的文件执行部分构建操作,以在进行本地开发时缩短构建时间。”
在我的测试中,我证实了这一点。我 运行 eleventy --incremental --serve
并注意到当我更改它时它一次只会重建一个文件。如果你 运行 它自己,它每次都会创建一个完整的构建,如此处记录:https://www.11ty.dev/docs/usage/incremental/#cold-start