https://forums.slime2.stream/forums/help.13/
It's not necessary to build widgets using this, but if you do then you get the added benefit of hot reloading and using .env.local
for your tokens instead of directly including them in SLIME2_*_KEY.js
.
You'll need to install:
Use git to clone the repo.
Open the folder using the code editor of your choice.
In the terminal, navigate to the repo (VS Code terminal will already be there), and run this command:
npm install
In the widgets
folder, create a copy of the slime-chat
folder. Rename it and the slime-chat
files to the name of your custom widget. The folder structure should look like this:
...
š widgets
\_š custom-widget
\_š overlay-custom-widget.html
\_š README.txt
\_š script-custom-widget.js
\_š settings-custom-widget.js
\_š styles-custom-widget.css
\_š slime-chat
\_š overlay-slime-chat.html
\_š README.txt
\_š script-slime-chat.js
\_š settings-custom-widget.js
\_š styles-slime-chat.css
...
Duplicate the .env.production
file, renaming the copy to .env.local
. In the file, set the values to the keys that you can download from https://slime2.stream/account. For example, setting the Twitch key would look like this:
VITE_TWITCH_KEY = 'yourKeyHere'
Run this command, substituting custom-widget
with the name of your widget:
npm run widget custom-widget
The overlay should automatically open up in your web browser, and if you edit anything in your widget's custom folder, it will automatically update when you save! (Also known as hot reloading)
Once you're ready to package and release your widget, run this command, substituting custom-widget
with the name of your widget:
npm run build:widget custom-widget
This will create a new widgets/release/custom-widget
folder using the name of your widget, which will look like this:
...
š widgets
\_š release
\_š custom-widget
\_š overlay-custom-widget.html
\_š README.txt
\_š script-custom-widget.js
\_š settings-custom-widget.js
\_š styles-custom-widget.css
...
{version}
with the slime2 version number, and replaces all instances of {widget}
with your widget name.SLIME2_*_KEY.js
files, since they shouldn't be included in a public build.Zip all of the release/custom-widget
files and name the .zip
whatever you want. I would recommend something like Custom Widget 1.0.0.zip
. Whenever you make a new update, update that version number accordingly!
Distribute that .zip
file however you want! And if you just want to use your widget yourself, copy all of those files into a separate folder, copy in the SLIME2_*_KEY*.js
file that you already downloaded from https://slime2.stream/account, and load your HTML file into a browser source in OBS as a local file!
I personally recommend distributing via Ko-fi, because anyone who downloads/buys something from your shop there will automatically follow you, they'll always know when you put a new item into your shop, you can send a notice to all your followers when you've made an update, and buyers will always have access to the latest file! (Which doesn't happen on Etsy, where buyers can only download the file that was there at the time that they bought it.)
Bonus Tip: Use the widgets
folder itself as a git repo to easily track and version control your own widget development!
Bonus Tip 2: If you create a widgets-private
folder, you can use the commands npm run private
and npm run build:private
instead of npm run widget
and npm run build:widget
, allowing you to create widgets in there that are ignored by git. You can use that folder as a private repo as well!