我在我的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)中的每个文件都会被修改。每个文件的修改时间都会发生变化。
我是不是遗漏了什么?
我希望文件只被修改,源文件的修改日期也改变了吗?
发布于 2021-11-02 15:33:22
我相信incremental只能和serve一起使用。医生说:
“增量生成仅在进行本地开发时为缩短生成时间而更改的文件上执行部分生成。”
在我的测试中,我确认了这一点。我运行了eleventy --incremental --serve,并注意到当我更改它时,它一次只能重建一个文件。如果您自己运行它,它每次都会创建一个完整的构建,如下所示:https://www.11ty.dev/docs/usage/incremental/#cold-start
https://stackoverflow.com/questions/69779416
复制相似问题