Configuration

Parcel configuration can be shared between projects by publishing a .parcelrc file in a package on npm. This also allows multiple plugins to be distributed together.

Shared configuration

#

This example shows how a company might distribute a shared Parcel configuration to be used between projects. It extends @parcel/config-default and adds several additional plugins.

package.json:
{
"name": "@company/parcel-config",
"main": "index.json",
"version": "1.0.0",
"engines": {
"parcel": "2.x"
}
}
index.json:
{
"extends": "@parcel/config-default",
"transformers": {
"*.svg": ["...", "@parcel/transformer-svg-react"]
},
"namers": ["@company/parcel-namer", "..."],
"compressors": {
"*.{js,html,css}": [
"...",
"@parcel/compressor-gzip",
"@parcel/compressor-brotli"
]
}
}

Multi-plugin packages

#

In addition to sharing configuration between projects, Parcel config packages are also useful to distribute multiple plugins that are required to work together. For example, a transformer and packager combination may be needed for a new file format.

Note: In this case, it's best to not extend the default Parcel config and allow users of your config package to choose which default to extend from.

package.json:
{
"name": "parcel-config-xml",
"main": "index.json",
"version": "1.0.0",
"engines": {
"parcel": "2.x"
}
}
index.json:
{
"transformers": {
"*.xml": ["parcel-transformer-xml"]
},
"packagers": {
"*.xml": "parcel-packager-xml"
}
}

Once published, users can now consume parcel-config-xml in their projects by extending it in addition to the default config of their choice.

.parcelrc:
{
"extends": ["@parcel/config-default", "parcel-config-xml"]
}