首页 > 解决方案 > vite 无法处理 xxx.html 文件

问题描述

我有一个 Vue2 的 Vite 项目,它包含一个静态 html 文件。

喜欢以下

import template from 'editor.html';
export default {
    template: template
}

当我运行yarn dev时,终端输出:

node_modules/@gaoding/editor-framework/lib/base/editor.js:23:21:错误:没有为“.html”文件配置加载器:node_modules/@gaoding/editor-framework/lib/base/editor.html 23 │ 从 './editor.html' 导入模板;

我试图在下面添加一些插件vite.config.ts,但所有这些都不起作用。

@rollup/plugin-html

汇总插件 html

汇总插件 htmlvue

我怎么解决这个问题。

标签: htmlpluginsloaderrollupvite

解决方案


?raw在导入结束时添加可以解决问题:

import template from "./contact-list.html?raw";  

我仍在寻找如何为所有 HTML 文件全局设置它的解决方案。


推荐阅读