CLI
The parcel
CLI is the most common way to use Parcel. It supports three different commands: serve
, watch
, and build
.
parcel [serve] <entries>
#The serve
command starts a development server, which will automatically rebuild your app as you change files, and supports hot reloading. It accepts one or more file paths or globs as entries. serve
is the default command, so it may also be used by passing entries directly to parcel
.
parcel src/index.html
See Development for more details.
parcel watch <entries>
#The watch
command is similar to serve
, but does not start a dev server (only a HMR server). However, it automatically rebuilds your app as you make changes, and supports hot reloading. Use watch
if you're building a library, a backend, or have your own dev (HTTP) server. See below for how to specify entries.
parcel watch src/index.html
parcel build <entries>
#The build
command performs a single production build and exits. This enables scope hoisting and other production optimizations by default. See below for how to specify entries.
parcel build src/index.html
See Production for more details.
Entries
#All Parcel commands accept one or more entries. Entries may be relative or absolute paths, or globs. They may also be directories containing a package.json
with a source
field. If entries are omitted entirely, the source
field in the package.json
in the current working directory is used. See Entries in the Targets documentation for more details.
# Single file
parcel src/index.html
# Multiple files
parcel src/a.html src/b.html
# Glob (quotes required)
parcel 'src/*.html'
# Directory with package.json#source
parcel packages/frontend
# Multiple packages with a glob
parcel 'packages/*'
# Current directory with package.json#source
parcel
Parameters
#These parameters are supported by all Parcel commands.
Format | Description |
---|---|
--target [name] | Specifies the targets to build. May be specified multiple times. See Targets. |
--dist-dir <dir> | Output directory to write to when unspecified by targets. Default value for the distDir option in package.json targets . |
--public-url <url> | The path prefix for absolute urls. Default value for the publicUrl option in package.json targets . |
--no-source-maps | Disables sourcemaps, Overrides the sourceMap option in package.json targets . |
--config <path> | Specify which Parcel config to use. Can be a file path or package name. Defaults to @parcel/config-default . See Parcel configuration. |
--reporter <package name> | Run the specified reporter plugin in addition to the ones specified in the .parcelrc . Can be specified multiple times. |
--log-level (none/error/warn/info/verbose) | Sets the log level. |
--cache-dir <path> | Sets the cache directory. Defaults to .parcel-cache . See Caching. |
--no-cache | Disables reading from the filesystem cache. See Caching. |
--profile | Profiles the build (a flamechart can be generated). |
-V, --version | Outputs the version number. |
Parameters specific to serve
and watch
#Format | Description |
---|---|
-p, --port <port> | The port for the dev server and HMR (the default port is process.env.PORT or 1234). See Dev server. |
--host <host> | Sets the host to listen on, defaults to listening on all interfaces |
--https | Runs the dev server and HMR server over HTTPS. |
--cert <path> | Path to a certificate to use. See HTTPS. |
--key <path> | Path to a private key to use. See HTTPS. |
--no-hmr | Disables hot reloading. |
--hmr-port <port> | The port for the HMR server (defaults to the dev server's port). See Hot reloading. |
--hmr-host <host> | The host for the HMR server (defaults to the dev server's host). See Hot reloading. |
--no-autoinstall | Disables auto install. |
--watch-for-stdin | Stop Parcel once stdin is closed. |
Parameters specific to serve
#Format | Description |
---|---|
--open [browser] | Automatically opens the entry in your browser. Defaults to the default browser. See Dev server. |
--lazy | Only builds bundles requested by the dev server. See Lazy mode. |
Parameters specific to build
#Format | Description |
---|---|
--no-optimize | Disables optimizations such as minification. Overrides the optimize option of package.json targets . See Production. |
--no-scope-hoist | Disables scope hoisting. Overrides the scopeHoist option of package.json targets . See Scope hoisting. |
--no-content-hash | Disables content hashing of output file names. Bundle names may still include hashes, but they will not change on each build. See Content hashing. |
--detailed-report [depth] | Displays the largest 10 (number configurable with depth ) assets per bundle in the CLI report. See Detailed report. |