For contributors
Architecture
Section titled “Architecture”This project uses Turborepo to manage build process.
Project structure
Section titled “Project structure”apps
- applications.docs
- documentation website.
demos
- demos.inline
- inline demos for various pages outside of specific framework context.*
- demos for each supported framework.
packages
- loader itself, integrations and internal utilities.integration-utils
- utility functions and constants for integrations. Bundled with the loader to allow users to write their own integrations.loader
- loader’s source code.types
- types for the integrations.utils
- common utilities.*-integration
- specific framework integration.vite-astro-entry-generator
- a plugin that generates an Astro component that loads a script on the client side.vite-awesome-svg-loader
- final loader bundle.vite-file-tree-builder
- a plugin that builds a project’s file tree.
modules.d.ts
- types for untyped external modules.
Demos are self-contained NPM packages.
All demos should contain their own scripts and assets. The code and the assets are often duplicated across the demos.
When demo is built, its file tree is formed that will be displayed in the docs website.
Demos should be small and should not have a sprawling file tree.
Demos are built in Vite library mode and rebuilt whenever a change occurs. This pattern avoids necessity for the running multiple web servers.
Scripts
Section titled “Scripts”build
- builds whole project.build:packages
- builds all packages. Use this while developing to speed up the build.build:apps
- builds all apps.build:demos
- builds all demos.dev
- builds all packages and executesdev
all dev commands. This command is resource heavy!dev:docs:standalone
- runsdev
command fordocs
packages without running all demos in watch mode. This is a lighter alternative todev
. The docs are still updated whenever demo is rebuilt.lint
- lints the code with ESLint.format
- formats the code with Prettier.
Bundle structure
Section titled “Bundle structure”Every project (both in apps
and packages
directories) should be bundled into dist
directory inside project’s root.
For example, vue-demo
bundle is in apps/vue-demo/dist
directory.
TypeScript and JavaScript
Section titled “TypeScript and JavaScript”The primary language for this project is TypeScript. TypeScript should be used while developing loader itself, integrations and demos.
However, build scripts are written in JS to simplify development and speed up the build. Typing is not critical for these scripts. Thus, TypeScript is just not worth it.
Dependencies
Section titled “Dependencies”Dependencies that are used by more than one project should be installed for the whole project, i.e. added to the root package.json
.
Such dependencies include Vite, TypeScript, Vue, React, Solid, etc.
Local dependencies should be installed in package or app where they’re required.
vite-awesome-svg-loader
final bundle dependencies always should be in packages/vite-awesome-svg-loader/package.json
file even if they’re duplicated in the root package.json
.
Code style
Section titled “Code style”Prettier should be used to format the code. Styles that are left for the user to decide are handled by ESLint rules.
This project tries to keep the source code clean and readable. Please, try to do so as well, i.e. don’t stack if
s too many times, don’t use bit shifts unnecessarily, etc.
Integrations development
Section titled “Integrations development”- Create an issue to notify the community that you’ll be working on your integration.
- Create integration package using
npx turbo generate workspace
command or by copying an existing integration. - Develop integration:
- Open
package.json
file inside your integration directory. - Add
"integration-utils": "*"
dependency. - Develop your integration.
- Open
- Update
vite-awesome-svg-loader
package with your integration:- Open
packages/vite-awesome-svg-loader/package.json
. - Add your integration to the
exports
andtypesVersions["*"]
fields. Basically copy already existing entry and change directory name. Unfortunately, we can’t point to anotherpackage.json
and shouldn’t dynamically create a package.
- Open
- Develop demos for your integration:
- Duplicate any existing demo and pages in the
/apps/docs/src/content/docs
directory. - Develop your demos.
- Update the docs:
- Add a glob import for the demos inside
/apps/docs/src/demos
directory. - Update the previously copied pages.
- Feel free to add your own pages if needed.
- Add a glob import for the demos inside
- Duplicate any existing demo and pages in the
- Submit a PR with your integration.
Loader development
Section titled “Loader development”- Create an issue to notify the community that you’ll be working on your feature.
- Develop your feature. Make sure to document it with JSDoc.
- Update the docs to showcase your feature.
- Test if demos work.
- Submit a PR.