如何为使用`create-react-app CLI`创建的现有React应用程序生成bundle.js [英] How to generate bundle.js for existing react app created using `create-react-app CLI`

查看:99
本文介绍了如何为使用`create-react-app CLI`创建的现有React应用程序生成bundle.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题与相关发布。我在项目中使用 create-react-app CLI 。这是一个小型Web应用程序,我通过 npm start 在本地启动,并显示在浏览器中。现在,我需要为整个Web应用程序生成一个 bundle.js 文件,以便它可以与 Adob​​e Phonegap 一起使用。

This question is related to this SO post. I'm using create-react-app CLI for my project. It is a small scale web app which I start (locally) by npm start and it appears on browser. Now I need to generate a bundle.js file of my entire web app so that it can be used with Adobe Phonegap. How do I do that with my existing app?

推荐答案

反应脚本构建应该这样做。将 build 字段添加到 package.json 脚本部分c>文件,然后运行 npm run build 。示例:

react-scripts build should do it. Add a build field to the scripts section of your package.json file and then run npm run build. Example:

{
  "repository": {
    ...
  },
  ...
  "dependencies": {
    ...
  }
  "scripts" : {
    ...
    "build" : "react-scripts build"
  }
}

这篇关于如何为使用`create-react-app CLI`创建的现有React应用程序生成bundle.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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