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

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

问题描述

每次我推送到 heroku 时,它都会简单地说未找到".我假设这是因为 webpack 没有运行?

Every time I push to heroku it simply says "Not Found". I am assuming it is because webpack doesn't run?

我尝试了各种脚本:

"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.

安装后的那个会给我一个错误,说没有安装 webpack(保存在我的 devDependencies 下).第二,我在 Heroku 日志上成功构建,但在加载页面时未找到".

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.

推荐答案

您需要将 webpack(以及您在 Heroku 上需要的任何其他依赖项)放在 package.json 中的dependencies"下,而不是devDependencies"下.

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天全站免登陆