How to run production build of a ReactJS app with Parcel bundler?

Viewed 580

I'm just trying to generate a build using parcel build /src/index.html, I'm able to build the app, but when I try to open the build form a browser, it says it is unable to access index.js from index.html after build.

<body>
    <div id="root"></div>
    <script src="index.js" type="module"></script>
</body>

Anyway, Im having no issues on running the project locally. Please take a look at the images below to understand my concern. Thanks.

Console error after opening index.html from build

Project structure

1 Answers

You need to serve the dist directory from a web server.

F.I. from your terminal:

cd dist
npx serve
Related