在Heroku上托管使用Wepback构建的生产React应用程序 [英] Hosting a production React app built with Wepback on Heroku

查看:111
本文介绍了在Heroku上托管使用Wepback构建的生产React应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我推送到heroku时,它都会显示未找到。我假设这是因为webpack不运行?



我尝试了各种脚本:

 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆