Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear doc about javascript configuration with CLI tool #238

Closed
gael-boyenval opened this issue Jan 29, 2019 · 5 comments · Fixed by #249
Closed

Unclear doc about javascript configuration with CLI tool #238

gael-boyenval opened this issue Jan 29, 2019 · 5 comments · Fixed by #249

Comments

@gael-boyenval
Copy link

gael-boyenval commented Jan 29, 2019

The doc is a bit unclear about the ability to use javascript file instead of JSON with CLI tool.

By default, Style Dictionary looks for a config.json file in the root of your package. You can also specify a custom location when you use the CLI. If you want a custom build system using the npm module, you can specify a custom location for a configuration file or use a plain Javascript object.

reading the doc, it imply that we may only use JS config with the nom module.
but in fact, using JS file seem to work properly using cli tool as well. Here my CLI command :

npx style-dictionary build --config ./src/tokens/config.js
@dbanksdesign
Copy link
Member

Good catch. We added javascript module support for config files and didn't update all of the documentation. If you would like, feel free to open a PR to update the documentation.

P.S. Nice use of npx!

@gael-boyenval
Copy link
Author

@dbanksdesign, I would like to, but I need some context :

By default, will style-dictionary look for either a config.js or config.json file ?
Support for the plain javascript object file path is supported by either CLI arg and NPM ?

I would love to update the doc, but I don't want to dive too deep into the code right now. I have limited available time. :)

@dbanksdesign
Copy link
Member

No worries! I can also update the documentation if I get some time this week. By default the style dictionary CLI will only look for config.json:
https://github.com/amzn/style-dictionary/blob/master/bin/style-dictionary#L62

Although, I feel like it would make sense to look for both config.js and config.json by default, so maybe we should change that...

And javascript object is supported by both CLI and NPM. Really the CLI is a pretty basic wrapper around the NPM module. The NPM module accepts a string, which can be a path to anything that require understands like a javascript file with module.exports = {} or a plain JSON file. The NPM module can also accept a plain object as well:

const StyleDictionary = require('style-dictionary').extend({
  source: ['properties/*.json'],
  platforms: {
    scss: {
      transformGroup: 'scss',
      buildPath: 'build/',
      files: [{
        destination: 'variables.scss',
        format: 'scss/variables'
      }]
    }
    // ...
  }
});

@gael-boyenval
Copy link
Author

@dbanksdesign thank's

@chazzmoney
Copy link
Collaborator

Created a PR, #247

chazzmoney added a commit that referenced this issue Feb 19, 2019
…tion (#249)

feat(config): use config.js if config.json is not found; updating documentation

Added functionality to search / use 'config.js' in root if 'config.json' is not found in root.
Modified documentation to ensure clarity around using JS based config with the CLI.

fix: #238
docs: #238
replaces #247 to be from master branch instead of develop
dbanksdesign pushed a commit that referenced this issue Feb 19, 2019
Added functionality to search / use 'config.js' in root if 'config.json' is not found in root.
Modified documentation to ensure clarity around using JS based config with the CLI.

fix: #238
docs: #238
replaces #247 to be from master branch instead of develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants