mirror of
https://github.com/m5stack/m5-docs.git
synced 2026-05-20 10:23:01 -07:00
1.8 KiB
1.8 KiB
Build Process
Here is what the build system is doing under the hood.
CLI
- The build system looks for a config file. By default it looks for config.json in the current directory, or you can specify the config path with the
-c --configflag. - If there is an
includesattribute in the config, it will take those JSON files and deep merge them into thepropertiesobject. - It then takes all the JSON files in the
sourceattribute in the config and performs a deep merge onto thepropertiesobject. - Then it iterates over the platforms in the config and:
- Perform all transforms, in order, defined in the transforms attribute or transformGroup.
- Build all files defined in the files array
- Perform any actions defined in the actions attribute
Node
If you use this as a node module, the steps are slightly different, but the overall.
- When you call the
extendmethod, you can either pass it a path to a JSON config file, or give it a plain object that has the configuration. This will perform steps 1-3 above. - Then you can now call
buildAllPlatformsor other methods likebuildPlatform('scss')orexportPlatform('javascript'). This is equivalent to step 4 above.
const StyleDictionary = require('style-dictionary');
const styleDictionary = StyleDictionary.extend( 'config.json' );
// is equivalent to this:
// const styleDictionary = StyleDictionary.extend(
// JSON.parse( fs.readFileSync( 'config.json' ) )
// )
// You can also extend with an object
// const styleDictionary = StyleDictionary.extend({ /* config options */ });
// This will perform step 3 above, for each platform:
// 1. Apply transforms
// 2. Build files
// 3. Perform actions
styleDictionary.buildAllPlatforms();
