Production Environment


Production environment
When you need to package an application for use in a production environment, you can use Parcel's production mode.

parcel build entry.js

This will disable watch mode and module hot swapping, so it will only build once. It also enables the minifier used to compress the output package file size. Minifiers used by Parcel include uglify-es for JavaScript, cssnano for CSS, and htmlnano for HTML.
To enable production mode, you also need to set the NODE_ENV = production environment variable. Large libraries like React have development debugging features, which can be disabled by setting this environment variable, making production builds smaller and faster.
Options
Set the output directory
Default: "dist"

parcel build entry.js --out-dir build/output
或者
parcel build entry.js -d build/output
root
- build
- - output
- - - entry.js

Set the public URL to be served
Default: --out-dir option

parcel build entry.js --public-url ./

Will output:

<link rel="stylesheet" type="text/css" href="1a2b3c4d.css">
or
<script src="e5f6g7h8.js"></script>

Disable compression
Default: minification enabled

parcel build entry.js --no-minify

Disable file system cache
Default: cache enabled

parcel build entry.js --no-cache