首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >11ty:--增量没有任何影响?

11ty:--增量没有任何影响?
EN

Stack Overflow用户
提问于 2021-10-30 11:58:35
回答 1查看 86关注 0票数 1

我在我的package.json上使用了这个

代码语言:javascript
复制
{
  "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,我正在用它来测试:

代码语言:javascript
复制
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)中的每个文件都会被修改。每个文件的修改时间都会发生变化。

我是不是遗漏了什么?

我希望文件只被修改,源文件的修改日期也改变了吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-02 15:33:22

我相信incremental只能和serve一起使用。医生说:

“增量生成仅在进行本地开发时为缩短生成时间而更改的文件上执行部分生成。”

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69779416

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档