Configuration
A bsconfig.json file in your project's root tells bsc how to build your project. Most projects only need a few options. Everything else is in the bsconfig.json reference.
Create a bsconfig.json
npx bsc --initThis writes a bsconfig.json with recommended defaults, followed by every other option, commented out, with a short description of each. An existing bsconfig.json is never overwritten.
A minimal config
If your project's files live in a src folder, this is all you need:
{
"rootDir": "src",
"stagingDir": "out/staging",
"retainStagingDir": true,
"sourceMap": true
}It keeps the staging folder around after each build, which is handy for inspecting the transpiled output, and turns on source maps so the debugger shows your original source code.
Options you'll use most
| Option | What it does |
|---|---|
rootDir | The folder your manifest lives in |
files | Which files are part of the project, if not everything under rootDir |
stagingDir | Where the transpiled files go |
sourceMap | Debug your original source code instead of the transpiled output |
autoImportComponentScript | Automatically import the .bs file next to each component's .xml file |
diagnosticFilters | Hide errors and warnings you don't care about |
host and password | The Roku device to deploy to with --deploy |
Tips
-
Add
bscto yourpackage.jsonscripts, so everyone runs the same command:package.json{ "scripts": { "build": "bsc", "watch": "bsc --watch" } } -
Keep secrets out of the repo. Pass your device's password on the command line (
bsc --deploy --host 192.168.1.10 --password secret) instead of putting it inbsconfig.json. -
Share settings between configs with
extends. For example, absconfig.dev.jsoncan extendbsconfig.jsonand only override what's different, and you build with it usingbsc --project bsconfig.dev.json. -
Every option also works on the command line. Run
bsc --helpfor the full list.
All options
The table above only covers the basics. There are many more options for diagnostics, source maps, plugins, deploying and more.