Customizing Parcel with custom .parcelrc
Plasmo allows you to customize the Parcel bundler configuration by using a custom .parcelrc
file. This file lets you override or extend the default settings, enabling you to tailor the build process to your project's specific needs.
Overview
The .parcelrc
file is a JSON configuration file placed in the root of your project. It defines how Parcel processes your assets by specifying transformers, bundlers, namers, and runtimes.
If you don't create a .parcelrc
file, Plasmo will use its default configuration. However, advanced use cases can leverage a custom file to introduce custom behavior or integrate additional plugins.
Important: For your Plasmo project to build correctly, the custom configuration file must extend @plasmohq/parcel-config
. This ensures that all necessary default settings and optimizations are inherited for seamless integration with Plasmo's build system.
Example
Using custom parcel namer
{
"extends": "@plasmohq/parcel-config",
"namers": ["parcel-namer-hashless"]
}
This config setup and applies a custom namer plugin to generate hashless file names.
Conclusion
The .parcelrc
file is a powerful tool for customizing the Parcel bundler within your Plasmo projects. By tweaking the configuration, you can optimize the build process, integrate custom plugins, and tailor the toolchain to your project’s needs.