How to build with different bsconfig schema in dev/prod mode?

I’d like to change the bsc-flags in dev/prod mode respectively. Is there any suggested way in the CLI flag or any bsconfig scheme to resolve this need?

No, you will have to do something custom if you want to have different bsc-flags for different envs.

1 Like

I’ve stumbled upon a similar problem too and found no clever solution. If your prod build toolchain allows messing the contents of the bsconfig, here’s a possible script sample to adjust settings:

#!/usr/bin/env node

 * If a bsconfig.json have some dependencies under 'bs-dev-dependencies',
 * `bsb -make-world` tries to find them too even in production builds.
 * There’s currently no way to tell `bsb` to ignore them.
 * This script takes a path to a `bsconfig.json` and rewrites it with
 * with 'bs-dev-dependencies' reset to an empty array and dev sources
 * removed.
 * Use in Dockerfiles.

const fs = require('fs');
const JSON5 = require('json5');

const path = process.argv[2] || 'bsconfig.json';
const content = fs.readFileSync(path, { encoding: 'utf8' });
let conf = JSON5.parse(content);
conf['bs-dev-dependencies'] = [];
conf['sources'] = conf['sources'].filter(src => src.type !== 'dev');

fs.writeFileSync(path, JSON.stringify(conf));



Thank you for your tip.

We use sed in my app. To remove "-bs-g" from the bsc-flags, and set warnings as errors, we do

sed -i -f bin/disable_debug.sed bsconfig.json.
where disable_debug.sed has two lines:

s/"error": false/"error": true/

This probably doesn’t work on windows, but that’s not a concern for us.

Thanks for you tip!
I’m considering either way to switch multiple bsconfig files or to use the sed command like your advice.

not a bad place for Dhall