plug-in
Plugins
Parcel takes a slightly different approach than many other packaging tools in that many common formats are included out of the box, with no need to install and configure additional plugins. However, there are cases where you may want to extend Parcel in a non-standard way, in which case you can use plugins to support this. Installed plugins are automatically detected and loaded based on package.json dependencies.
When adding support for a new file format to Parcel, you should first consider how widely used it will be and how standardized it will be implemented. If it were widespread and standard enough, this format should probably be added to Parcel core, rather than existing as a plugin that users need to install. If you have any questions, GitHub is a great place to discuss them.
Plugin API
The Parcel plugin is very simple. They are just modules that export a single function, which is automatically called by Parcel during initialization. This function receives a Bundler object as input and can perform configuration such as registering asset resources and bundlers.
module.exports = function (bundler) { bundler.addAssetType('ext', require.resolve('./MyAsset')); bundler.addPackager('foo', require.resolve('./MyPackager')); };uses the parcel-plugin- prefix and publishes this package to npm, where it will be automatically detected and loaded as described below.
Using plugins
Using plugins in Parcel is very easy. All you need to do is install them and save them to your package.json. Plugins should be named with the parcel-plugin- prefix, e.g. parcel-plugin-foo . Any dependencies listed in package.json will be automatically loaded on initialization.