Setting up production builds

Unlike the Angular CLI, you don't need extra scripts to perform a production build with the Create React App tool. You should already have the build command in your package.json file for that:

{
"scripts": {
"serve": "react-scripts start",
"start": "electron .",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
}

Whenever you need to perform a production build, use the following command in the Terminal:

npm run build

In this case, the output should look as follows:

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

36.83 KB build/static/js/2.6efc73d3.chunk.js
763 B build/static/js/runtime~main.d653cc00.js
725 B (+15 B) build/static/js/main.dff8d9a2.chunk.js
540 B build/static/css/main.0e186509.chunk.css

The project was built assuming it is hosted at ./.
You can control this with the homepage field in your package.json.

As you can see, all the production assets reside in the build folder. Now, you can distribute or host the resulting web application without the need for Node.js or any other tool:

Many developers prefer to host web applications in a local server to greatly reduce the time they need to spend testing the end result. You may also want to follow that path and only have the build folder before you package your Electron application for the final testing and publishing stages.

Now, let's learn how to configure the use of local web servers for development purposes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.150.59