18534

How to run build version using create-react-app?

Question:

So, I developed a small React application using create-react-app. (I have always made applications from scratch.)

Then, after I was kind of happy with it, I decided to run npm run build to make an optimized production build.

Can someone please tell me how I can run the production build instead of the Dev build?

Answer1:

When you run npm run build your console should actually say something like the following

The build folder is ready to be deployed. You may serve it with a static server: npm install -g serve serve -s build

The build script is building your entire app into the build folder, ready to be statically served. However actually serving it require some kind of static file server, like the the one they propose.

After running the command serve -s build you can access your production build at localhost (on the specified port).

You can of course run whatever static file server you like, I usually use express for this, however serve seems like the easiest option to just serve your statics files with a single command.

Recommend

  • Is there a way to group nth-child CSS rules for same parent
  • Rails + Amazon RDS : latency issues
  • Why integer division and modulo isn't optimized out in NVRTC
  • Making a vectorized numpy function behave like a ufunc
  • Azure Resource Template Deployment issues
  • npm thinks node is out of date, but it isn't
  • Deploy same Javascript webapp build to different environments
  • AOT and JIT with build-optimizer
  • When interface inheritance in Java is useful?
  • Trouble connecting to Google Cloud SQL server from deployed app
  • Microsoft Chart Controls for Microsoft .NET Framework 4.0
  • Grunt watch Running “watch” task Waiting
  • Cordova Apache wrong module path
  • Mercurial: Identify file name after rename
  • What is the use of a session store?
  • File extension of zlib zipped html page?
  • Using Laravel 5.4 pusher
  • Getting media player state in windows phone 7
  • perl, mysql - fasting way to upload a csv file into mysql?
  • Uncaught TypeError: $(…).select2 is not a function
  • How to generate and display a QR Code in ionic 2
  • Button click event not firing in jQuery
  • Installing iPhone App to iPhone
  • chrome.tabs.executeScript only fires when the Developer Console is open
  • JSON response opens as a file, but I can't access it with JavaScript
  • VSO Build — Response status code does not indicate success: 404 (Not Found)
  • Installing Hadoop, Java Exception about illegal characters at index 7?
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Convert array of 8 bytes to signed long in C++
  • Upload files with Ajax and Jquery
  • How to pass list parameters for each object using Spring MVC?
  • SVN: Merging two branches together
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • Arrays break string types in Julia
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • Proper way to use connect-multiparty with express.js?
  • -fvisibility=hidden not passed by compiler for Debug builds
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • Net Present Value in Excel for Grouped Recurring CF