好了,现在我已经读了很多关于stackoverflow的不同问题,没有任何运气,他们似乎都去了一个旧版本的webpack-dev-server。
我已经尝试了很多事情,但没有任何运气,我的小应用程序根本不会重新加载/重建超过一次。
我所做的更改是在app. tsx中添加和删除文本。
标签中。
我希望有人能给予我一点提示
图片显示了我在更改后保存。
我的webpack.config
const path = require("path");
module.exports = {
mode: "development",
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "public"),
filename: "main.js",
},
target: "web",
devServer: {
port: "3000",
static: ["./public"],
open: true,
hot: false,
liveReload: true,
},
resolve: {
extensions: [".js", ".jsx", ".json", ".ts", ".tsx"],
},
module: {
rules: [
{
test: /\.(ts|tsx|js|jsx)$/,
exclude: /node_modules/,
use: "babel-loader",
},
],
},
};
我的软件包. json
{
"name": "reactone",
"version": "1.0.0",
"description": "",
"main": "./src/index.js",
"scripts": {
"start": "webpack serve --mode development --env development",
"build": "webpack",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.17.9",
"@babel/eslint-parser": "^7.17.0",
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",
"@babel/runtime": "^7.17.9",
"babel-loader": "^8.2.4",
"babel-plugin-transform-scss": "^1.1.0",
"css-loader": "^6.7.1",
"dart-sass": "^1.25.0",
"html-webpack-plugin": "^5.5.0",
"sass-loader": "^12.6.0",
"style-loader": "^3.3.1",
"webpack": "^5.72.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.8.1"
},
"dependencies": {
"@types/node": "^17.0.24",
"@types/react": "^18.0.4",
"@types/react-dom": "^18.0.0",
"mobx": "^6.5.0",
"mobx-react": "^7.3.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"typescript": "^4.6.3"
}
}
我的文件设置
2条答案
按热度按时间aurhwmvo1#
我也遇到了同样的问题。在我的例子中,问题出在文件导入上。
而不是
问题是
Component
单词的小写字母c
,而不应该是大写的C
。数小时的不成功搜索,因为一个字母:D92dk7w1h2#
多亏了你的文章,我找到了同样问题的原因
我的配置如下所示:
我希望这对你有帮助
除此之外,我还附加了一个指向我的构建配置的链接,以便全面了解webpack-template