Getting started with Parcel


Getting Started
Parcel is a Web application packager (bundler) that is different from the packagers used by previous developers. It leverages multi-core processing to deliver blazingly fast performance, and you don’t need to configure anything.
First use Yarn or npm to install Parcel:
Yarn:

yarn global add parcel-bundler

npm:

npm install -g parcel-bundler

Create a package.json file in your project directory using the following command:

yarn init -y
or
npm init -y

Parcel can use any type of file as an entry point, but an HTML or JavaScript file is a good Start. If you use a relative path to link your main JavaScript file into the HTML, Parcel will also handle this for you and replace that reference with the URL of the output file.
Next, create an index.html and index.js files.

<html>
<body>
  <script src="./index.js"></script>
</body>
</html>
console.log("hello world");

Parcel has a built-in development server, which automatically rebuilds your application when you change files, and supports module hot replacement so you can develop quickly. You only need to specify the entry file:

parcel index.html

Now open http://localhost:1234/ in your browser. You can also override the default port using the -p <port number> option.
If you do not have your own server, or your application is entirely client-rendered, please use a development server. If you have your own server, you can run Parcel in watch mode. In this way, when the file changes, Parcel will still automatically rebuild the file and support module hot replacement, but will not start the web server.

parcel watch index.html

When you are preparing to build for production, build mode turns off monitoring and will only build once. See section Production for more details.