如何为使用`create-react-app CLI`创建的现有React应用程序生成bundle.js [英] How to generate bundle.js for existing react app created using `create-react-app CLI`
问题描述
此问题与此相关发布。我在项目中使用 create-react-app CLI
。这是一个小型Web应用程序,我通过 npm start
在本地启动,并显示在浏览器中。现在,我需要为整个Web应用程序生成一个 bundle.js
文件,以便它可以与 Adobe 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 $的
脚本
部分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屋!