Rollup Plugin Scriptable
Create a Scriptable bundle from your project
Installation
npm i -D @jag-k/rollup-plugin-scriptable
Usage
import scriptableBundle from "@jag-k/rollup-plugin-scriptable";
import * as config from "./config.json";
export default {
input: 'src/index.js',
output: [
{
file: `dist/widget.js`,
format: 'es',
plugins: [scriptableBundle(config)]
}
]
};
// config.json
{
"always_run_in_app": false,
"icon": {
"color": "blue",
"glyph": "users"
},
"name": "Widget",
"share_sheet_inputs": []
}
After build, you will get 2 files:
dist
├── HASS Persons.js
└── HASS Persons.scriptable
In .js
file added banner for Scriptable app.
.scriptable
file contains bundle for Scriptable app.
This is config.json
file with script
key which value is compiled code.
Quick Tips
You can use rollup-plugin-copy
to copy files to iCloud for easy
development and debugging Scriptable scripts.
import { homedir } from 'os';
import scriptableBundle from '@jag-k/rollup-plugin-scriptable';
import copy from 'rollup-plugin-copy';
import * as config from './config.json';
export default {
input: 'src/main.js',
output: [
{
file: `dist/${config.name}.js`,
format: 'es',
plugins: [scriptableBundle(config)]
},
],
plugins: process.env.COPY_TO_ICLOUD === 'true' ? [
copy({
hook: 'writeBundle',
targets: [
{
src: `dist/*.js`,
dest: `${homedir()}/Library/Mobile Documents/iCloud~dk~simonbs~Scriptable/Documents/`
},
]
})
] : []
};
License
Apache 2.0