我是 reactjs 的新手。 我尝试使用包括 index.js(包含 console.log())在内的基本索引页面配置反应,但是当我尝试运行服务器 index.html 显示正确但 bundle.js 未加载时。 我搜索了很多,但没有得到正确的答案,请任何人帮助我。
我的 webpack.config.js 是
// Webpack config js.
var webpack = require("webpack");
var path = require("path");
var DIST_VAR = path.resolve(__dirname, "dist");
var SRC_VAR = path.resolve(__dirname, "src");
var config = {
entry : SRC_VAR + "\\app\\index.js",
output: {
path: DIST_VAR + "\\app\\",
filename: "bundle.js",
publicPath : "\\app\\",
},
module: {
rules: [
{
test: /\.js?/,
include: SRC_VAR,
loader: "babel-loader",
query: {
presets: [ "react" , "es2015" , "stage-2"]
}
}
]
}
};
module.exports = config;
控制台中显示错误:源为“ http://localhost:8080/app/bundle.js ”的加载失败。
编辑:
添加了文件夹列表.. 文件夹路径列表卷序列号为 BE9C-4E51
C:.
| package-lock.json
| package.json
| webpack.config.js
|
+---dist
| | index.html
| |
| \---app
| bundle.js
|
+---node_modules
| <Here the node_modules>
\---src
| index.html
|
\---App
index.js