Skip to content

OnroerendErfgoed/vue_component_library

Repository files navigation

Vue component library

Vue components based on @govflanders Webuniversum components with our own branding applied.

Recommended IDE Setup

VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar) + Vue VSCode Snippets

Type Support for .vue Imports in TS

TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue types.

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:

  1. Disable the built-in TypeScript Extension
    1. Run Extensions: Show Built-in Extensions from VSCode's command palette
    2. Find TypeScript and JavaScript Language Features, right click and select Disable (Workspace)
  2. Reload the VSCode window by running Developer: Reload Window from the command palette.

Customize configuration

See Vite Configuration Reference.

Code style

Pre-commit hook

See Pre-commit for installation.

After installing this on your local machine, the config in .pre-commit-config.yaml will be picked up and makes sure lint and format are run before commit to guarantee the code style.

Lint and format on save (VSCode)

Add following config to your settings.json to enable lint and format on save.

{
  ...,
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "[vue]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[yaml]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[scss]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}

Project Setup

yarn

Development with Storybook

yarn storybook

Build and watch for Development in implementing applications

yarn build:watch

Yalc - for sharing locally developed packages across your local environment. - https://github.com/wclr/yalc

Yalc publish

Afterwards link the package in the desired implementing application.

yalc add @OnroerendErfgoed/[email protected]
yalc update
yarn

Type-Check, Compile and Minify for Production

yarn build

Run Headed Component Tests with Cypress Component Testing

yarn test:unit:dev # or `yarn test:unit` for headless testing

Run End-to-End Tests with Cypress

yarn test:e2e:dev

This runs the end-to-end tests against the Vite development server. It is much faster than the production build.

But it's still recommended to test the production build with test:e2e before deploying (e.g. in CI environments):

yarn build
yarn test:e2e

Lint with ESLint

yarn lint

Format with Prettier

yarn format