This is a template for a plugin for the Vendure e-commerce framework.
It is intended for plugins which are to be distributed as npm packages, either publicly or privately. If you are building a one-off plugin for a specific project, it probably makes more sense to simply nest those plugins into the project source, as is demonstrated by the real-world-vendure folder structure
Further information on how Vendure plugins can be used can be found in the vendure.io Plugins documentation.
The scaffold in this repo can be used to populate a new plugin directory with the following bash command:
curl https://codeload.github.com/vendure-ecommerce/plugin-template/tar.gz/master | \tar -xz --strip=2 plugin-template-master/srcSee src/e2e for details, run tests with:
yarn testThis repository can automatically generate GraphQL types for use in the plugin code (see src/e2e/plugin.e2e-spec.ts). To generate the types, ensure the development server is running, and use the command:
yarn dev:generate-typesThis repository uses eslint & Prettier for finding and fixing common code issues and formatting your code in a standard way. To identify and fix issues, use the command:
yarn lint:fixThis repository also implements a basic Admin UI extension, which displays and allows editing of the Example entity. These UI screens make use of the BaseList, BaseDetail, and BaseResolver classes, which are helpful for handling CRUD operations.
A development server is configured in the dev-server folder, using Docker and Docker Compose to spin up a Postgres database, as well as a server and worker. This is used to test the plugin during development.
To start the server, run:
yarn dev:runTo populate or reset the database, run the following command:
yarn dev:populateTo restart the server (only) after a change, use the following command:
yarn dev:restartNote: The Docker containers must be rebuilt when updating dependencies. Use the following command:
yarn dev:rebuild