Skip to content

ynx0/parcel-optimizer-header

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

parcel-optimizer-header

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.

How to use

Install

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.

Configure parcel

.parcelrc

{
  "extends": "@parcel/config-default",
  "optimizers": {
    "*.js": ["...", "parcel-optimizer-header"]
  }
}

Example Output

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(){...

Credits

Thanks to @sogaani for making https://github.com/sogaani/parcel-optimizer-add-license which this is based off of.

About

prepend a userscript header to the final bundled file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%