为什么 webpack 尝试解析我的 readme.md 文件 [英] Why does webpack try to parse my readme.md files
问题描述
Webpack 抛出如下所示的错误.构建似乎仍然有效,是什么给出了?
Webpack throws errors shown below. The build seems to work, still, what gives?
./{snip}/readme.md 中的警告模块解析失败:C:{snip}\readme.md Unexpected token (1:7)您可能需要一个合适的加载器来处理这种文件类型.
WARNING in ./{snip}/readme.md Module parse failed: C:{snip}\readme.md Unexpected token (1:7) You may need an appropriate loader to handle this file type.
我找不到任何方法来忽略文件.我什至不知道它为什么要渲染这些文件.
I could not find any way to ignore files. I don't even know why it is trying to render those files.
这是我的 webpack 设置文件的一些部分:
Here are some parts of my webpack settings file:
module: {
loaders: [
{test: /\.hb.html$/, loader: "handlebars-loader/?helperDirs[]=" + __dirname + "/src/handlebarsHelpers"},
{ test: /\.tsx?$/, loader: "ts-loader?" + JSON.stringify({
transpileOnly: true
})}
]
},
条目:
entry: "./src/entry.ts",
和
resolve: {
extensions: ["", ".webpack.js", ".web.js", ".ts", ".tsx", ".js"],
我尝试在打字稿配置文件中排除 .md 文件,也没有奏效.
I tried excluding .md files in typescript config file, also didn't work.
推荐答案
问题不在于设置,而是我的代码有这样的查询表达式:
The problem wasn't the settings, it was that my code had query expressions like these:
exports.getModule = function (moduleName) {
var mod = require('./' + moduleName + '');
return mod;
};
这使得 webpack 尝试加载所有文件,而不仅仅是入口点依赖树上的文件.
That made webpack try to load all the files, not only the ones on the entry point dependency tree.
这篇关于为什么 webpack 尝试解析我的 readme.md 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!