npx ng g @nrwl/angular:lib ngx-ui --directory=shared --tags=scope:shared,type:ui --prefix=shared-ngx-ui
2. Angular用のShared-UIにコンポーネントを作る
npx ng g component components/toggle --project=shared-ngx-ui --exportnpx ng g directive directives/input --project=shared-ngx-ui --export
3. Angular用のShared-UIにStorybookの導入
インストール
npm install --save-dev @nrwl/storybook
設定の作成
npx nx g @nrwl/angular:storybook-configuration shared-ngx-ui
? Configure a cypress e2e app to run against the storybook instance? Yes
? Automatically generate *.stories.ts files for components declared in this library/application? Yes
? Automatically generate *.spec.ts files in the cypress e2e app generated by the cypress-configure generator? Yes
npx nx g @nrwl/angular:storybook-configuration shared-ui
コンポーネントがないためspecファイルが作れないので、e2eインスタンスのみ作成する。
? Configure a cypress e2e app to run against the storybook instance? Yes
? Automatically generate .stories.ts files for components declared in this library/application? No
? Automatically generate .spec.ts files in the cypress e2e app generated by the cypress-configure generator? No
概要
nrwl/nxにstorybookを導入する。
storybook導入時に、既存のコンポーネントに合わせて
.stories
を作ってくれるので、先にコンポーネントを用意しておく。方針として
ngx
という名前をプロジェクト名につける1. Angular用のShared-UIライブラリを作る
@nrwl/angular:lib
を利用する。ngx-
とつけることで、名前からAngular用のライブラリだとわかる--prefix
を指定することで、任意のprefixをつけることができるnpx ng g @nrwl/angular:lib ngx-ui --directory=shared --tags=scope:shared,type:ui --prefix=shared-ngx-ui
2. Angular用のShared-UIにコンポーネントを作る
npx ng g component components/toggle --project=shared-ngx-ui --export
npx ng g directive directives/input --project=shared-ngx-ui --export
3. Angular用のShared-UIにStorybookの導入
インストール
npm install --save-dev @nrwl/storybook
設定の作成
npx nx g @nrwl/angular:storybook-configuration shared-ngx-ui
4. Angular用のShared-UIのStorybookの実行
npx nx run shared-ngx-ui:storybook
5. Angular非依存のShared-UIライブラリを作る
6. Angular用のShared-UIにscssファイルを作る
libs/shared/ui/src/lib/scss
に、color.scss
を作る6. Angular非依存のShared-UIにStorybookの導入
npx nx g @nrwl/angular:storybook-configuration shared-ui
コンポーネントがないため
spec
ファイルが作れないので、e2eインスタンスのみ作成する。? Configure a cypress e2e app to run against the storybook instance? Yes ? Automatically generate .stories.ts files for components declared in this library/application? No ? Automatically generate .spec.ts files in the cypress e2e app generated by the cypress-configure generator? No
8. Angular非依存のShared-UIのscssのstoriesを作る
libs/shared/ui/src/lib/scss/stories
の下に、color.scss.stories.scss
とcolor.scss.stories.ts
を作るcolor.scss.stories.scss
color.scss.stories.ts
7 . Angular非依存のShared-UIにStorybookの実行
npx nx run shared-ngx-ui:storybook