Warning
This plugin has not been extensively tested and there we offer NO GUARANTEES.
🙃
This plugin lets you add prepend a static header to every bundle,
as defined in a file called header.toml
that goes in the root of your project. (Or really anywhere that config.getConfig
will find it.)
This can be useful for things like licenses or userscript headers, which normally get stripped out.
Use a direct git URL in your npm deps because I haven't published it to npm. Or you could just clone vendor it and use a file:
url. Or self-publish it.
.parcelrc
{
"extends": "@parcel/config-default",
"optimizers": {
"*.js": ["...", "parcel-optimizer-header"]
}
}
Given a header.toml
that looks like
# example header file;
# put this in your project directory
header = '''
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 2024-01-01
// @description try to take over the world!
// @author You
// @match https://example.com
// @grant none
// ==/UserScript==
'''
Every bundle will look something like:
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 2024-01-01
// @description try to take over the world!
// @author You
// @match https://example.com
// @grant none
// ==/UserScript==
!function(){...
Thanks to @sogaani for making https://github.com/sogaani/parcel-optimizer-add-license which this is based off of.