- Standalone mode support
- A master-app built-in support
- Pre-configured environment
- Vite
- TypeScript
- Husky + lint-staged
- ESLint
- Prettier
- Built-in and pre-configured demo-app
A part of the master - slave blueprint-setup for a quick Vue application kickstart.
Useful in cases where a Vue application depends on a shared library developed by the same team as the application itself.
This is the slave part of the setup.
If this slave-lib implements the sub-slaving pattern, go to the next nested slave.
Read the rationale first. The "Todo UI" example from there is referenced below.
- Clone the repo
- Rename the folder to "todo_ui"
rm -rf .git && git init
to re-initialize the.git
folder in order to detach the library from this repository
Make the following changes in the cloned files (4 files in total):
-
package.json
- Change the package
name
to "todo_ui" - In the
module
field, change the"vite-vue-starter-slave"
part to"todo_ui"
- In the
env:prep
script, change the"npm link vite-vue-starter-slave"
part to"npm link todo_ui"
- After
todo_ui
from the previous step, separated by space list all the slave's subslaves - In the
peerDependencies
section, change"vite-vue-starter-slave": "file:./"
to"todo_ui": "file:./"
- If there are other slave-libs for this slave-lib, specify them in
dependencies
- Duplicate all the necessary peer-deps in dev-deps for the demo app to work
- Change the package
-
vite.lib.config.ts
,vite.demo.config.ts
andtailwind.config.cjs
- Address all the
TODO
s inside these files
- Address all the
Run npm i
and then npm run env:prep
.
Now you can focus on developing the actual library inside the /src
folder. Vue components, separate modules and scripts - whatever comprises your lib.
In order to get the lib tested, you need to make use of the library in the demo app and then to serve this demo app.
- Navigate to the
/demo
folder and make use of the library's exports - Make sure to reference the library as you would do from and other application (i.e. not using the relative
/src
-paths). You should be able to instead import everything from your lib withimport TodoUI from "todo_ui"
, which becomes possible thanks to theenv:prep
script invoked earlier that self-links the lib into the demo - Get the demo app up and running with
npm run dev:demo
- For the demo to respect live-changes to the library's code (i.e. for the lib to auto-recompile on changes), get the lib's watcher-server up with
npm run dev:lib
Continue developing and testing the library.
When done, build the /dist
folder with npm run build
command and refer to the master-library's README (or repeat the process for the next slave-lib in the sub-slaving chain).
- The demo app is a good candidate to be shared with GitHub Actions to GitHub Pages to provide your library users with an ability to see it live.
- The type-declaration output files are not rebuilt by the dev-server. That's if the master-app doesn't see the TypeScript-related changes you introduce into the slave-lib, you need to manually restart the dev-server for
vue-tsc
to rebuild the types or instead simply invoke thenpm run build:lib
command. The same applies to the demo as well, since the/dist
folder's contents are used by the demo rather than the lib's source files.