diff --git a/src/core/formats.ts b/src/core/formats.ts index 2b01d36..6ea5003 100644 --- a/src/core/formats.ts +++ b/src/core/formats.ts @@ -1,4 +1,4 @@ -import { cssTemplate, esmTemplate } from './templates' +import { cssTemplate, esmTemplate, jsonTemplate } from './templates' function getFileNameWithPlatform(fileName: string, platform: string, extension: string): string { if (platform === 'common') { @@ -43,6 +43,20 @@ export const formats: Formats = { } return result }, + 'json.whitepaper': (platforms) => { + const result = [] + for (const platform in platforms) { + const layers = platforms[platform] + for (const layer in layers) { + const { name, tokens } = layers[layer] + result.push({ + fileName: getFileNameWithPlatform(name, platform, 'json'), + content: jsonTemplate(tokens), + }) + } + } + return result + }, 'js.esm': (platforms, options) => { const result = [] for (const platform in platforms) { diff --git a/src/core/templates.ts b/src/core/templates.ts index 2e10f98..0d03454 100644 --- a/src/core/templates.ts +++ b/src/core/templates.ts @@ -39,9 +39,13 @@ export function esmTemplate(tokens: FlattenToken[]): string { result += generateFileHeader() for (const token of tokens) { if (token.comment !== undefined) { - result += `// ${token.comment}\n` + result += `/** ${token.comment} */\n` } result += `export const ${token.name} = '${token.value}';\n` } return result } + +export function jsonTemplate(tokens: FlattenToken[]): string { + return JSON.stringify(tokens, null, 2) +}