【问题标题】:vite cannot handle xxx.html filesvite 无法处理 xxx.html 文件
【发布时间】:2021-07-23 14:57:18
【问题描述】:

我有一个 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/编辑器.html 23│从'./editor.html'导入模板;

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

@rollup/plugin-html

汇总插件-html

rollup-plugin-htmlvue

我该如何解决这个问题。

【问题讨论】:

    标签: html plugins loader rollup vite


    【解决方案1】:

    在导入末尾添加?raw 可以解决问题:

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

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

    【讨论】:

      猜你喜欢
      • 2022-11-14
      • 2022-09-25
      • 2014-08-25
      • 1970-01-01
      • 1970-01-01
      • 2015-03-09
      • 2017-05-07
      • 2013-12-08
      • 2019-08-24
      相关资源
      最近更新 更多