我的 Cloudflare Worker 项目中有以下导入语句,用于将 html 文件作为字符串常量导入:
import userAgentJsch from './userAgentJsch';
import { parse } from 'cookie';
import test from '.test.html';
它失败并出现错误:
找不到模块:错误:无法解析“.test.html”
我正在阅读有关需要配置我的webpack.config.js文件的信息,但我没有这样的文件。
你能帮忙吗?我只是想让我的 html 文件与 js 文件分开,但我找不到我能理解的解决方案。
毫无疑问,视图文件夹结构用于渲染模板
要读取 nodejs 中的文件,请使用以下命令:
const fs = require("fs");
const files = fs.readFileSync("new.html");
并导入
var htmlContent = require('path/to/html/file.html');
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句