Skip to content
SiteEmail

Existing projects

Projects created with the gameface-ui template from create-gameface-app are already wired up and need nothing from this page.

Every other starting point needs a one-time setup, including the plain solid template. create-gameface-app scaffolds several frameworks, and only the Gameface UI template ships the aliases and style variables that components depend on.

The CLI prints a Setup required note the first time it installs into a project it doesn’t recognise. This page is what that note refers to.

  1. Install sass

    Component stylesheets are written in SCSS. It is a build-time tool rather than a runtime dependency, so the CLI does not install it for you.

    Terminal window
    npm install -D sass
  2. Add the @components alias to tsconfig.json

    Components import each other through this alias, so TypeScript needs to resolve it:

    tsconfig.json
    {
    "compilerOptions": {
    "baseUrl": ".",
    "paths": {
    "@components/*": ["src/components/*"],
    "@assets/*": ["src/assets/*"]
    }
    }
    }
  3. Add the same aliases to your Vite config

    TypeScript path mappings only affect type checking. Vite resolves imports at build time and needs to be told separately:

    vite.config.ts
    import { defineConfig } from 'vite';
    import solid from 'vite-plugin-solid';
    import path from 'node:path';
    export default defineConfig({
    plugins: [solid()],
    resolve: {
    alias: {
    '@components': path.resolve(__dirname, './src/components'),
    '@assets': path.resolve(__dirname, './src/assets'),
    },
    },
    });
  4. Set up the style variables

    Every component stylesheet expects a set of shared SCSS variables to be available. Create the file at src/assets/scss/_variables.scss:

    src/assets/scss/_variables.scss
    // Your design tokens: colours, spacing, typography.
    // Component styles reference these, so the names must exist.
    $primaryColor: #868599;
    $secondaryColor: #3e3d5d;
    $disabledColor: #bdbdbd;
    $textColor: #ffffff;
    $disabledTextColor: #dddedf;

    Then inject it into every SCSS file so components don’t have to import it themselves:

    vite.config.ts
    export default defineConfig({
    // ...plugins and resolve as above
    css: {
    preprocessorOptions: {
    scss: {
    additionalData: `@use '@assets/scss/variables' as *;`,
    },
    },
    },
    });

Once that is in place, npx gameface-cli add <component> behaves exactly as it does in a Gameface UI project.

A plain Solid project after the setup above, with one component installed. Highlighted files are the ones you write or edit yourself.

  • package.json the CLI records what it installed here, under gameface-ui-components
  • tsconfig.json the @components and @assets paths from step 2
  • vite.config.ts the matching aliases and the SCSS injection from steps 3 and 4
  • Directorysrc
    • main.tsx
    • App.tsx
    • Directoryassets
      • Directoryscss
        • _variables.scss your design tokens, injected into every stylesheet
    • Directorycomponents your components and the CLI’s, side by side
      • DirectoryBaseComponent
        • BaseComponent.tsx
      • DirectoryBasic
        • DirectoryButton
          • Button.tsx
          • Button.module.scss
      • DirectoryUtility
        • DirectoryNavigation
          • Navigation.tsx
          • …
      • Directorytypes
        • ComponentProps.d.ts
        • …
      • Directoryutils
        • waitForFrames.ts
        • …
      • DirectoryHUD yours, and the CLI will never touch it
        • HUD.tsx
        • HUD.module.scss

Only Button was asked for. BaseComponent, Utility/Navigation, types and utils came along as its dependencies, which is why the folder looks fuller than a single install suggests. Those shared folders are reused by every component, so the next few installs add much less.

There is no separate folder to keep your components in. Put them wherever you like, src/components/ included - the CLI has no opinion about what else is in there.

What it does have is a fixed list of paths it owns. On every add and update it writes those paths from the registry, overwriting whatever is there without merging and without asking. Inside src/components/, that list is:

BaseComponent/ Basic/ Complex/ Feedback/ Layout/ Media/ Utility/ types/ utils/

Components that need a full Gameface project

Section titled “Components that need a full Gameface project”

Icon and Keybinds are not available outside a Gameface UI project. They depend on generated type files, an icon-generation script, and gamepad glyph assets that only exist in the full template, so installing them here would leave you with components that don’t build.

If you need them, start from create-gameface-app with the gameface-ui template instead.

ProblemFix
Cannot find module '@components/...'The alias is missing from tsconfig.json, from your Vite config, or from both. Each needs its own copy: TypeScript uses it for type checking, Vite for resolving the actual import.
Undefined variable errors from SCSSEither _variables.scss does not exist, additionalData is not injecting it, or the variable names do not match. Component styles reference specific names such as $primaryColor, $secondaryColor and $textColor, so your own tokens have to use those names rather than equivalents of your own choosing.
npm installation failedThe component files were written, but installing their npm dependencies did not work. The CLI prints the exact command to run by hand. A pre-existing unresolvable dependency in your package.json is the usual cause, since npm resolves the whole tree on any install.
Gameface UI components require a SolidJS projectsolid-js is not in your package.json. Install it, or start from the gameface-ui template.
status shows almost nothing installed, but the components are clearly thereThey were never recorded under gameface-ui-components. Run npx gameface-cli track to register what is already on disk.
track reports a component as behind that you never touchedIts files differ from the published version, which usually means they are simply from an older release. Run with --verbose to see exactly which files differ.
Styles are missing after an updateThe update replaced a stock component you had edited in place. Re-apply the change as a wrapper or through props so it lives at a path of your own, then re-run the update.
A file of your own disappeared after add or updateIt was at a path the registry owns. Recover it from source control and move it out of BaseComponent/, Basic/, Complex/, Feedback/, Layout/, Media/, Utility/, types/ and utils/ - anywhere else under src/components/ is safe.