0
Fork 0
mirror of https://github.com/penpot/penpot-export.git synced 2025-01-07 15:39:00 -05:00
penpot-export/README.md

101 lines
3.5 KiB
Markdown
Raw Normal View History

# penpot-export
2023-08-21 01:36:47 -05:00
## Description
`penpot-export` is an npm tool designed to export your design components created in Penpot directly to CSS files. With a simple `pce` command, you can convert your designs into ready-to-use CSS classes.
2023-08-21 01:36:47 -05:00
## Installation
To install `penpot-export`, simply run:
2023-08-21 01:36:47 -05:00
```bash
# npm
npm install penpot-export --save-dev
2023-08-21 01:36:47 -05:00
# yarn
yarn add penpot-export
2023-08-21 01:36:47 -05:00
```
## Configuration
Before you can use `penpot-export`, you need to set up a [`penpot-export.config.js`](./packages/demo/penpot-export.config.js) file at the root of your project. This file defines how your Penpot designs will be exported.
2023-08-21 01:36:47 -05:00
Configuration example:
```js
require('dotenv').config()
/**
* @type {import('penpot-export').UserConfig}
2023-08-21 01:36:47 -05:00
*/
const config = {
instance: process.env.PENPOT_BASE_URL || undefined,
2023-08-21 01:36:47 -05:00
accessToken: process.env.PENPOT_ACCESS_TOKEN,
2023-08-31 13:28:14 -05:00
files: [
2023-08-21 01:36:47 -05:00
{
2023-08-22 04:36:13 -05:00
fileId: 'abea3ef6-4c19-808a-8003-01370d9cb586',
2023-08-31 13:28:14 -05:00
pages: [
{
pageId: '71b1702b-2eb1-81d6-8002-f82a5f182088',
output: 'src/styles/ui.css', // 👈 Path where your CSS file should be generated.
},
],
},
{
fileId: '4a499800-872e-80e1-8002-fc0b585dc061',
colors: [
{
output: 'src/styles/colors.css', // 👈 Path where your CSS file should be generated.
},
],
typographies: [
{
output: 'src/styles/typographies.css', // 👈 Path where your CSS file should be generated.
},
],
2023-08-21 01:36:47 -05:00
},
],
}
module.exports = config
```
## Usage
Once you've set up the `penpot-export.config.js` file, simply run the following command to generate your CSS files:
2023-08-21 01:36:47 -05:00
```bash
pce
```
2023-08-31 13:28:14 -05:00
This will read your Penpot designs and generate CSS files in the places specified in your configuration file.
2023-08-21 01:36:47 -05:00
## Development
### Using Yarn Workspaces
2023-08-21 01:41:36 -05:00
This project utilizes [Yarn Workspaces](https://classic.yarnpkg.com/lang/en/docs/workspaces/) to manage multiple packages within a single repository. This allows us to house the module's source code and a demo in separate packages, streamlining development and testing.
2023-08-21 01:36:47 -05:00
2023-08-21 01:43:42 -05:00
> **Why Yarn Workspaces?**
> _Your dependencies can be linked together, which means that your workspaces can depend on one another while always using the most up-to-date code available._ - [Reference](https://classic.yarnpkg.com/lang/en/docs/workspaces/#toc-why-would-you-want-to-do-this)
2023-08-21 01:36:47 -05:00
### Package Structure
- [**packages/penpot-export**](./packages/penpot-export/): This package contains the CLI tool written in TypeScript. This is where the primary tool code resides.
2023-08-21 01:36:47 -05:00
- [**packages/demo**](./packages/demo/): This package serves as a demonstration environment. You can run the `pce` command within this package to test out implementations in development.
### Local Development
For the "demo" package to utilize the local version of the `pce` command you're developing, it's essential first to compile the TypeScript code from the "penpot-export" package.
2023-08-21 01:36:47 -05:00
### Handy Commands
To facilitate the development process, we've set up the following commands that can be run at the repository's root:
- **yarn dev**: Runs the CLI tool in development mode. Ideal for making changes and seeing real-time results.
- **yarn build**: Compiles the TypeScript code in production mode. Ensure you run this command before testing the tool in the "demo" package.
- **yarn demo**: Runs the `pce` command within the "demo" package. It's handy for quickly testing implementations after making changes to the source code.
We recommend following this workflow: make changes to the code, run `yarn build`, and then `yarn demo` to test your changes.