For reference, here is the file structure of the app:
project
│ README.md
│ shopify.app.toml
| Dockerfile
| heroku.yml
| package.json
| package-lock.json
│
└───web
│ │ index.js
│ │ vite.config.js
│ │ package.json
│ │ package-lock.json
│ │ shopify.web.toml
│ │
│ └───frontend (changed to public as a test)
│ │ App.jsx
│ │ index.html
│ │ index.jsx
│ │ package.json
│ │ package-lock.json
│ │ shopify.web.toml
│ │ vite.config.js
│ └─── components
│ └─── pages
| | index.jsx (home page)
│ └─── public
│ └─── static
│ └─── styles
│ └─── assets
│
| └─── helpers
| └─── middleware
I am trying to get my Shopify app to work on Heroku. I used the CLI which gives you a predefined file structure and includes specific files for functions etc. I’ve been using the script “shopify app dev” to run the app, but you cannot run the CLI commands in Heroku. Therefore, I need a way to run it locally with npm start. If I point to the App.jsx file using “node ./web/frontend/App.jsx”, I get an error:
Unknown file extension “.jsx”
I installed Babel but did not add any configurations (I was comparing to a regular react app created with npx create-react-app my-app).
If I use react-scripts, it needs a public folder. I changed the “frontend” folder to be named as “public” and changed all instances in the app where it used “frontend” as a folder name. The command I used to utilize react-scripts is:
cd web && react-scripts start
In which I get a different error: Could not find a required file. Name: index.js Searched in:
C:\Users\username\Documents\dev\my-app\web\src
Which means now I need a src file that contains index.js, however, the file structure has the index.js in the same directory as index.html.
I’m trying not to eject the app but I feel like that may be the option I have to go with. I just feel it is likely Shopify made the app to where it can run locally (our of the box) and perhaps I am missing something. Please help and thank you in advance!