Bundle a React App as a single file JS with Parcel

Viewed 358

I have a react app that opens a widget in a div. I want to bundle it using parcel, ideally as a single js file.

Currently my build command looks like this

// package.json
"build:widget": "parcel build src/index.js --no-source-maps -d docs"

which builds a folder of files. If I then include the index.css and index.js on a 3rd party/demo site, the app works. However it is missing the images as they are looked for relative to the host site's root, not the index.js files root.

Is it possible to combine the css and js into one convenient file, to help people add the embed to their sites?

Can I add images to the parcel so they are either embedded in the js or linked to the server/cdn where the index.js file is hosted?

0 Answers
Related