【发布时间】:2018-01-06 03:30:16
【问题描述】:
我有以下项目结构:
|-mainFile.js
|-scripts -
|-Library1.js
|-Library2.js
库文件使用 requirejs define([], function() {}) 语法。
因此我把它放到了 webpack.config.js 中:
module.exports = {
resolve: {
modules: [
path.resolve(__dirname, 'scripts'),
// The normal path
"node_modules"
]
},
/** ... **/
}
然后我在 mainFile.js 这是 webpack 的入口点:
require(["Library1", "Library2"], function(Library1, Library2) { ... });
我得到这个错误:
GET http://localhost:3000/0.js [HTTP/1.1 404 Not Found 3ms]
Error: Loading chunk 0 failed.
Stack trace:
onScriptComplete@http://localhost:3000/player/webpack_build.js:100:24
webpack_build.js:146:52
The resource from “http://localhost:3000/0.js” was blocked due to MIME type mismatch (X-Content-Type-Options: nosniff).[Learn More]
test_file.html Error: Loading chunk 0 failed.
所以 webpack 尝试加载一些 0.js 文件。那应该是什么?
【问题讨论】:
标签: javascript node.js webpack