|
2 | 2 |
|
3 | 3 | ## Running in Development Mode |
4 | 4 |
|
5 | | -To start Django Tailwind in development mode, run the following command in a terminal: |
| 5 | +### Option 1: Combined Development Server (Recommended) |
| 6 | + |
| 7 | +To start both Django server and Tailwind watcher simultaneously, run: |
| 8 | + |
| 9 | +```bash |
| 10 | +python manage.py tailwind dev |
| 11 | +``` |
| 12 | + |
| 13 | +This will start both processes using Honcho and provide a seamless development experience. Use `CTRL + C` to terminate both processes. |
| 14 | + |
| 15 | +### Option 2: Separate Processes |
| 16 | + |
| 17 | +To start only the Tailwind watcher in development mode, run the following command in a terminal: |
6 | 18 |
|
7 | 19 | ```bash |
8 | 20 | python manage.py tailwind start |
9 | 21 | ``` |
10 | 22 |
|
11 | 23 | This will start a long-running process that watches files for changes. Use `CTRL + C` to terminate the process. |
12 | 24 |
|
| 25 | +**Note:** When using the separate process approach, you'll need to run `python manage.py runserver` in another terminal to start the Django development server. |
| 26 | + |
| 27 | +## How Development Mode Works |
| 28 | + |
13 | 29 | Several things happen behind the scenes: |
14 | 30 |
|
15 | 31 | 1. The stylesheet is updated every time you add or remove a CSS class in a Django template. |
16 | 32 | 2. The `django-browser-reload` watches for changes in HTML and CSS files. When a Django template or CSS file is updated, the browser refreshes automatically, providing a smooth development experience without needing to reload the page manually. |
17 | 33 |
|
| 34 | +## Customizing the Development Setup |
| 35 | + |
| 36 | +### Procfile.tailwind Configuration |
| 37 | + |
| 38 | +When you run `python manage.py tailwind dev` for the first time, a `Procfile.tailwind` file is automatically created in your project root with the following default content: |
| 39 | + |
| 40 | +``` |
| 41 | +django: python manage.py runserver |
| 42 | +tailwind: python manage.py tailwind start |
| 43 | +``` |
| 44 | + |
| 45 | +This file defines the processes that Honcho will run simultaneously. Each line follows the format: `process_name: command_to_run`. |
| 46 | + |
| 47 | +### Customization Examples |
| 48 | + |
| 49 | +You can edit `Procfile.tailwind` to customize your development commands: |
| 50 | + |
| 51 | +``` |
| 52 | +django: python manage.py runserver 0.0.0.0:8080 |
| 53 | +tailwind: python manage.py tailwind start |
| 54 | +``` |
| 55 | + |
| 56 | +### Process Management |
| 57 | + |
| 58 | +- **Starting processes:** `python manage.py tailwind dev` starts all processes defined in the Procfile |
| 59 | +- **Stopping processes:** Press `Ctrl+C` to stop all processes gracefully |
| 60 | +- **Process output:** Each process is color-coded in the terminal for easy identification |
| 61 | + |
18 | 62 | ## Building for Production |
19 | 63 |
|
20 | 64 | To create a production build of your theme, run: |
|
0 commit comments