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",
"outDir": "out",
"compilerOptions": {
"sourceMap": true
}
}It writes the transpiled files to the out folder, 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 |
outDir | Where the transpiled files go |
compilerOptions | Options for how your code is validated and compiled, like the two below |
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 |
Tips
-
Add
bscto yourpackage.jsonscripts, so everyone runs the same command:package.json{ "scripts": { "build": "bsc", "watch": "bsc --watch" } } -
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, type checking and more.