Web Parceljs配置

Web Parceljs配置,web,frontend,bundler,parceljs,Web,Frontend,Bundler,Parceljs,我在index.html中导入html文件时遇到问题 mypackage.json { "name": "test", "version": "1.0.0", "description": "test", "author": "test", "license": "ISC", "dependencies": { "del": "^3.0.0", "i": "^0.3.6" }, "devDependencies": { "parcel-bu

我在index.html中导入html文件时遇到问题

mypackage.json

{
  "name": "test",
  "version": "1.0.0",
  "description": "test",
  "author": "test",
  "license": "ISC",
  "dependencies": {
    "del": "^3.0.0",
    "i": "^0.3.6"
  },
  "devDependencies": {
    "parcel-bundler": "^1.12.3"
  },
  "scripts": {
    "start": "parcel src/pages/index.html"
  }
}

我试着像这样在index.html中包含header.html,但没有成功。

如何在index.html页面上包含html文件?

试试这个插件:

它可能需要项目根目录中的以下
.posthtmlrc
文件(假定为
src
文件夹):


.posthtmlrc
似乎对我没有任何帮助

我是这样做的:

安装
posthmlinclude
npm i posthmlinclude--save dev

在地块项目的顶层创建名为
posthtml.config.js
的文件:

module.exports={
插件:[
require('posthtml-include')({
根:`${uuu dirname}/partials`//“partials”可以重命名
})
]
};
然后创建一个包含HTML文件的
/partials
文件夹。要包含它,请使用以下语法:

<h1>Welcome</h1>
<include src="test.html"></include>
欢迎您

posthtml模块和posthtml包含之间的区别是什么?
<h1>Welcome</h1>
<include src="test.html"></include>