adeo / mozaic-design-system

Mozaic Design System
https://mozaic.adeo.cloud
Apache License 2.0
68 stars 17 forks source link

fix(tools/tokens): custom source path should be relative to project root #1600

Closed Maxsky5 closed 1 week ago

Maxsky5 commented 1 week ago

I have read the contributing guidelines

Does this PR introduce a breaking change?

Describe the changes

We use Mozaic on the Front-End Enablers portal and we customized tokens to have our own primary colors. Here is our mozaic.config.js :

module.exports = {
  preset: 'adeo',
  tokens: {
    localTokensSrcPath: './src/styles/tokens/',
    localTokensExportPath: './dist/tokens/',
  },
  ...
};

It used to work for a while, but recently when we upgraded @mozaic-ds/tokens from 1.68.0 to 1.72.0, and our custom tokens where not taken into consideration anymore. After some investigations, it seems that now the localTokensSrcPath is relative to node_modules/@mozaic-ds/tokens/ and not the root of the project as it used to be. I updated our Mozaic configuration with the following and it works well:

module.exports = {
  preset: 'adeo',
  tokens: {
    localTokensSrcPath: '../../../src/styles/tokens/',
    localTokensExportPath: './dist/tokens/',
  },
  ...
};

However I think it's a bug. In version 1.68.0 the custom source path was calculated this way:

const source = localSrcPath
  ? [getPath('properties/**/*.json'), `${localSrcPath}properties/**/*.json`]
  : [getPath('properties/**/*.json')]

and now it's like this:

 if (customSourcePath)
    source.push(getPath`${customSourcePath}${sourceDir['lm']}`))

The method getPath shouldn't be called when computing the custom source path.