在Heroku上托管使用Wepback构建的生产React应用程序 [英] Hosting a production React app built with Wepback on Heroku
问题描述
我尝试了各种脚本:
scripts:{
clean:rimraf dist,
build:npm run clean&& NODE_ENV = production&& amp ; webpack -p --progress,
postinstall:npm run builds,
serve:webpack-dev-server
}
和另一个,只是没有安装后。
带postinstall的那个会给我一个错误,说webpack没有安装(保存在我的devDependencies下)。在第二种情况下,我在Heroku日志上成功构建,但在加载页面时出现未找到。
您需要在package.json中的依赖关系下,而不是在devDependencies下面放置webpack(以及你需要的任何其他依赖项)。
Every time I push to heroku it simply says "Not Found". I am assuming it is because webpack doesn't run?
I've tried all sorts of scripts:
"scripts": {
"clean": "rimraf dist",
"build": "npm run clean && NODE_ENV=production && webpack -p --progress",
"postinstall": "npm run builds",
"serve": "webpack-dev-server"
}
and another, just without the postinstall.
The one with the postinstall will give me an error, saying webpack wasn't installed (saved under my devDependencies). In the second I get a successful build on the Heroku log but "Not Found" when I load the page.
You need to put webpack (as well as any other dependencies that you need on Heroku) under "dependencies" in your package.json, not under "devDependencies".
这篇关于在Heroku上托管使用Wepback构建的生产React应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!