非常教程

Parcel参考手册

生产环境 | Production

生产环境 | Production

当需要绑定应用程序的时候,你可以使用 Parcel 的生产模式。

parcel build entry.js

这将关闭监听模式和热模块替换,所以它只会编译一次。它还会开启 minifier 来减少输出包文件的大小。Parcel 使用的 minifiers 有 JavaScript 的 uglify-es ,CSS 的 cssnano 还有 HTML 的 htmlnano。

启动生产模式还要设置环境变量 NODE_ENV=production 。像 React 这种只用开发调试功能的大型库,通过设置这个环境变量来禁用调试功能,从而构建得更小更快。

Options

设置输出目录

Default: "dist"

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

设置要提供服务的公共 URL

Default: --out-dir option

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

将输出到:

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

禁用压缩

Default: minification enabled

parcel build entry.js --no-minify

禁用文件系统缓存

Default: cache enabled

parcel build entry.js --no-cache

生产环境 | Production相关

Parcel

Parcel 是一个网络应用打包工具,适用于经验不同的开发者。它利用多核处理提供了极快的速度,并且不需要任何配置。

Parcel目录

1.快速开始 | quick start
2.资源 | resource
3.转换 | transform
4.代码拆分 | Code Splitting
5.热模块重载 | HMR
6. 生产环境 | Production
7.配方 | Recipes
8.进阶 | Advanced