API Reference
theme
Code Generation

Code Generation

The code generation can also be done programmatically. Consider the project with the structure:

    • shoreline.config.js
    • index.js
    • package.json
  • The configuration file is:

    import { defineConfig } from '@vtex/shoreline-theme'
    export default defineConfig({
    preset: 'base',
    tokens: {
    color: {
    primary: 'oklch(54% 0.212 340.41)',
    },
    },
    })

    The main script should call the async function theme, with the return type Promise<void>.

    import { theme } from '@vtex/shoreline-theme'
    async function generate() {
    await theme()
    }
    generate()

    The script runs on a node environment.

    {
    "scripts": {
    "start": "node index.js"
    }
    }

    In the case of typescript, you can use ts-node (opens in a new tab).

    {
    "scripts": {
    "start": "ts-node index.ts"
    }
    }

    The theme() generates the contents on the shoreline folder.

      • styles.css
      • types.d.ts
    • shoreline.config.js
    • index.js
    • package.json