less-watcher/README.md

66 lines
1.7 KiB
Markdown
Raw Normal View History

2023-07-29 22:18:34 +00:00
# Less watch for .less files
2023-07-29 23:01:10 +00:00
This is a super-light npm package that watches .less files and actively compiles them into .css files
2023-07-29 22:18:34 +00:00
---
2023-07-29 22:59:59 +00:00
## Prerequisites
You need `less` npm package insalled. you can add it your project by running:
```bash
npm install less
```
2023-07-29 23:07:10 +00:00
## Installation
To install this package simply run:
```bash
npm install lessc-watcher
```
2023-07-29 22:18:34 +00:00
## How to use
There are few different ways to run your less compiler
#### Basic usage
```bash
2023-07-29 23:28:54 +00:00
npx lessc-watcher --src ./folder --dst ./dist/less.css
2023-07-29 22:18:34 +00:00
```
This traverses the folder and searches for a `main.less` file. This file serves as the source for your bundled `.css` file. If you want to target a specific file, use:
```bash
2023-07-29 23:28:54 +00:00
npx lessc-watcher --src ./folder/src.less --dst ./dist/less.css
2023-07-29 22:18:34 +00:00
```
Or you can just watch an entire folder. In this case less-watch will searc for an entry file named `main.less`. Without this entry file, your compiler wouldn't work.
```bash
2023-07-29 23:28:54 +00:00
npx lessc-watcher --src ./folder --dst ./dist/less.css
2023-07-29 22:18:34 +00:00
```
#### Adding more source folders
You can add more source folders by using a comma(`,`) separator. Example:
```bash
2023-07-29 23:28:54 +00:00
npx lessc-watcher --src ./folder-1,./folder-2 --dst ./dist/folder-1.css,./dist/folder-2.css
2023-07-29 22:18:34 +00:00
```
**_NOTE:_** Your `--dst` input must match the number of comma-separated folders in your `src` input.
#### Advanced Features
2023-07-29 23:07:10 +00:00
lessc-watcher has more advanced features to better fine-tune your files
2023-07-29 22:18:34 +00:00
##### Ignore files
Ignore files/folders by enlosing the names in braces. Eg `(general).less`
##### Compile specific files
If you're watching an entire folder, you can compile specific files in that folder to a stanalone file. Example if you create a file named `[test].less` in your watch directory, in your distribution directory there will be an extra file named `test.css`.