Just one of the things I'm learning: https://github.com/hchiam/learning
Parcel is a web app bundler. It's like Webpack, but with much less friction to set up your build.
You can see an example here based directly off of a quick tutorial by Maks Akymenko.
npm install -g parcel
# v1 parcel-bundler has been deprecatedor with yarn:
yarn global add parcelMore: https://parceljs.org
parcel index.htmlAnd then open http://localhost:1234 in a browser.
The command above will auto-rerun whenever you save a file.
In other words, to automatically trim off unused code, and to shorten the code that is used, you run a different command:
parcel build index.html --experimental-scope-hoistingThis does not auto-rerun whenever you save a file, but you'll notice the smaller .js file sizes in the dist folder.
-
Make sure to use
inline="inline"when you link the .js file to the .html file:<script src="./index.js" inline="inline"></script>
-
Install parcel-plugin-inline-source as a development dependency:
npm install parcel-plugin-inline-source --save-dev
-
Then this command will use parcel-plugin-inline-source:
parcel build index.html --no-source-maps --no-cache
-
You might want to do this too:
rm dist/*.js; rm dist/*.jpg
https://parceljs.org/cli.html#options
For example: --out-dir, --port, --out-file, --https, --cache-dir
And this command to auto-open a browser tab:
parcel demo/index.html --open(To transform modern syntax into code accessible to older browsers without breaking native built-ins.)