ladle icon indicating copy to clipboard operation
ladle copied to clipboard

Support NX

Open dbani-dev opened this issue 3 years ago • 1 comments

Documentation to support NX monorepo setup.

Adding a target for libs/ui -> project.json as follows:

"stories": {
      "executor": "nx:run-commands",
      "options": {
        "command": "pnpm ladle serve"
      }
    }

and running nx run ui:stories runs successfully.

However is unable to resolve shared dependencies.

Screen Shot 2022-08-04 at 1 03 51 am

Do I need to add resolve alias to config.mjs?

dbani-dev avatar Aug 03 '22 17:08 dbani-dev

Do I need to add resolve alias to config.mjs?

vite.config.js can be used to set resolve.alias.

tajo avatar Aug 03 '22 19:08 tajo

Ok, this seems to work by setting up vite.config.ts:

import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
import path from 'path';

export default defineConfig({
  plugins: [tsconfigPaths()],
  resolve: {
    alias: {
      '@project/ui': path.resolve(__dirname, './libs/ui/src/index.ts'),
    },
  },
});

dbani-dev avatar Aug 16 '22 13:08 dbani-dev