I'm trying to setup my create-react-app instance with webpack-dev-server.
我正在尝试使用webpack-dev-server设置我的create-react-app实例。
This is my package.json file
这是我的package.json文件
{
"name": "reactgs",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-scripts": "1.0.14"
},
"scripts": {
"start": "react-scripts start",
"build": "webpack-dev-server --entry ./node_modules/react-scripts/bin/react-scripts.js --output-filename ./dist/bundle.js --inline --progress",
},
"devDependencies": {
"webpack-dev-server": "^2.9.1"
}
}
I don't have a webpack.config.js file.
我没有webpack.config.js文件。
When I run
当我跑
npm run build
The output appears as
输出显示为
The following line runs fine.
以下行运行正常。
npm start
I also have webpack setup fine on the same machine for a different project.
我也在同一台机器上安装了webpack,用于不同的项目。
Does anyone know how to properly configure webpack for create-react-app?
有谁知道如何为create-react-app正确配置webpack?
1 个解决方案
#1
0
npm start
does the HMR for you out-of-the box. It will host your application using webpack-dev-server --hot
itself. You just need to hook the HMR code to tell webpack what to watch and reload as necessary.
npm start为您提供开箱即用的HMR。它将使用webpack-dev-server --hot本身托管您的应用程序。您只需要挂钩HMR代码即可告诉webpack必要时要观看和重新加载。
This GitHub conversation offers a pretty decent simple solution for hooking HMR (https://github.com/facebookincubator/create-react-app/issues/2317) with and without Redux.
这个GitHub会话为使用和不使用Redux挂钩HMR(https://github.com/facebookincubator/create-react-app/issues/2317)提供了一个相当不错的简单解决方案。
#1
0
npm start
does the HMR for you out-of-the box. It will host your application using webpack-dev-server --hot
itself. You just need to hook the HMR code to tell webpack what to watch and reload as necessary.
npm start为您提供开箱即用的HMR。它将使用webpack-dev-server --hot本身托管您的应用程序。您只需要挂钩HMR代码即可告诉webpack必要时要观看和重新加载。
This GitHub conversation offers a pretty decent simple solution for hooking HMR (https://github.com/facebookincubator/create-react-app/issues/2317) with and without Redux.
这个GitHub会话为使用和不使用Redux挂钩HMR(https://github.com/facebookincubator/create-react-app/issues/2317)提供了一个相当不错的简单解决方案。