【问题标题】:11ty: --incremental not having any effect?11ty: --incremental 没有任何效果?
【发布时间】:2021-12-15 03:37:09
【问题描述】:

我在我的 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


    【解决方案1】:

    我相信增量仅用于服务。文档说:

    “增量构建仅对已更改的文件执行部分构建操作,以在进行本地开发时缩短构建时间。”

    在我的测试中,我证实了这一点。我运行eleventy --incremental --serve 并注意到当我更改它时它一次只会重建一个文件。如果你自己运行它,它每次都会创建一个完整的构建,如此处所述:https://www.11ty.dev/docs/usage/incremental/#cold-start

    【讨论】:

    • build 任务上没有开发增量功能的任何原因?
    • 我不太确定我明白了。您在上面定义了构建任务,对吧?我会使用增量服务,而构建通常应该只是 npx @11ty/eleventy。
    • 也许我没有正确表达自己。只是想知道是否有任何原因我们不能用--incremental 执行npx @11ty/eleventy,所以只有更改的文件会得到更新。
    • Afaik,该功能仅用于开发,而不是增量更新最终结果。 (我是根据文档中的假设说的。)
    猜你喜欢
    • 2018-06-14
    • 2019-06-19
    • 2017-07-18
    • 2010-10-17
    • 2012-11-25
    • 2013-10-10
    • 2016-08-26
    • 2013-10-17
    • 1970-01-01
    相关资源
    最近更新 更多