momocow / webpack-userscript

A Webpack plugin for userscript projects. 🙈
https://cow.moe/webpack-userscript/
MIT License
202 stars 21 forks source link

Does the @icon item have to be a URL address? #108

Open topkie opened 1 year ago

topkie commented 1 year ago

I have written a configuration with the @icon item as a base64-encoded image like this:

new UserscriptPlugin({
    headers: {
    // ...
    icon: 'data:image/x-icon;base64,...',
    // ...
    }
})

There is an error message like this:

[webpack-cli] HookWebpackError: Validation groups: main
An instance of Headers has failed the validation:
 - property icon has failed the following constraints: icon must be a URL address 

    at makeWebpackError (.\node_modules\.pnpm\webpack@5.88.0_webpack-cli@5.1.4\node_modules\webpack\lib\HookWebpackError.js:48:9)
    at .\node_modules\.pnpm\webpack@5.88.0_webpack-cli@5.1.4\node_modules\webpack\lib\Compilation.js:3068:12       
    at eval (eval at create (.\node_modules\.pnpm\tapable@2.2.1\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:34:1)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
-- inner error --
Error: Validation groups: main
An instance of Headers has failed the validation:
 - property icon has failed the following constraints: icon must be a URL address 

    at ValidateHeaders.validateHeaders (.\node_modules\.pnpm\webpack-userscript@3.2.2_webpack@5.88.0\node_modules\webpack-userscript\dist\features\validate-headers\impl.js:45:23)
    at .\node_modules\.pnpm\webpack-userscript@3.2.2_webpack@5.88.0\node_modules\webpack-userscript\dist\features\validate-headers\impl.js:17:73
    at _next0 (eval at create (.\node_modules\.pnpm\tapable@2.2.1\node_modules\tapable\lib\HookCodeFactory.js:75:10), <anonymous>:54:16)
    at eval (eval at create (.\node_modules\.pnpm\tapable@2.2.1\node_modules\tapable\lib\HookCodeFactory.js:75:10), <anonymous>:79:1)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
caused by plugins in Compilation.hooks.processAssets
Error: Validation groups: main
An instance of Headers has failed the validation:
 - property icon has failed the following constraints: icon must be a URL address 

Does the @icon item have to be a URL address?

momocow commented 1 year ago

Does the @ICON item have to be a URL address?

The truth is, I have no idea.

I found no clue about the use of @icon in data URI format, based on docs of the following 4 userscript engines.

TamperMonkey: userscript headers GreaseMonkey: metadata block GreasyFork: meta keys ViolentMonkey: metadata block

According to tampermonkey, @icon, @iconURL and @defaulticon are substitutes of each other. Noticing the name @iconURL, that is why I defined @icon to be an URL address.

If you found any docs or use cases of @icon in data URI format, please feel free to let me know, thank you!

:)

topkie commented 1 year ago

I learned this usage from other scripts, but I found some issues about it:

https://github.com/Tampermonkey/tampermonkey/issues/1500 https://github.com/violentmonkey/violentmonkey/issues/1130

I have only used Tampermonkey, I hope this is helpful.