gpt4 book ai didi

javascript - 将 Javascript 文件作为字符串导入?

转载 作者:行者123 更新时间:2023-11-30 07:13:14 25 4
gpt4 key购买 nike

我希望能够简单地执行从'file.js 导入文件,然后让文件成为file.js 中内容的字符串。我玩过 raw-loader 但它没有给我相同的内容(而是以不同的格式加载它)。有什么建议吗?

最佳答案

it doesn't give me the same contents (instead it loads it in a different format)

这似乎意味着您的配置中还有其他加载程序应用于该文件。您可以强制只使用 import 语句中的加载程序,方法是在其前面加上 !:

import file from '!raw-loader!file.js'

来自docs :

It's possible to overwrite any loaders in the configuration by prefixing the entire rule with !.

关于javascript - 将 Javascript 文件作为字符串导入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44029866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com