In your frontend assets directory, create a file called parcel-entry.js.
import "./scripts/index"; // this will point to an index.js or similar file
Then I made two scripts called npm_start.sh and npm_build.sh. Make those executable by running chmod +x <filename> on them. Those files contain code to delete any old build files and rebuild them according to the settings you put in the shell scripts:
For example, the npm_start.sh script looks like this:
# delete the existing build files
echo 'removing old build'
rm -rf ./codeselfstudy/static/dist
# build the assets and watch for changes
echo 'rebuilding the assets'
# here it points to the parcel-entry.js file,
# tells it where to put the build files (--out-dir),
# tells it what the public-path to the frontend build files is (--public-url),
# and tells it what to name the output files (--out-file), i.e., (main.js, main.css)
npx parcel codeselfstudy/static/src/parcel-entry.js \
--hmr-port 34471 \
--out-dir codeselfstudy/static/dist \
--public-url /static/dist/ \
Then in your main package.json file, point the start and build scripts at the relevant shell scripts: