https://github.com/lekhmanrus/esbuild-pug
esbuild plugin to work with pug (jade) files
https://github.com/lekhmanrus/esbuild-pug
build-tool build-tools esbuild esbuild-loader esbuild-plugin esbuild-plugins hacktoberfest html-template html-template-engine jade javascript plugin plugins pug pugjs typescript
Last synced: about 2 months ago
JSON representation
esbuild plugin to work with pug (jade) files
- Host: GitHub
- URL: https://github.com/lekhmanrus/esbuild-pug
- Owner: lekhmanrus
- License: mit
- Created: 2024-10-10T18:53:48.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-10-10T19:48:14.000Z (8 months ago)
- Last Synced: 2025-03-17T16:06:56.406Z (2 months ago)
- Topics: build-tool, build-tools, esbuild, esbuild-loader, esbuild-plugin, esbuild-plugins, hacktoberfest, html-template, html-template-engine, jade, javascript, plugin, plugins, pug, pugjs, typescript
- Language: TypeScript
- Homepage:
- Size: 101 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
esbuild-pug
![]()
esbuild plugin to work with pug (jade) files.
[](https://github.com/lekhmanrus/esbuild-pug/actions/workflows/build.yaml)
[](https://github.com/lekhmanrus/esbuild-pug/actions/workflows/publish.yaml)
[](https://codecov.io/gh/lekhmanrus/esbuild-pug)
[](https://www.npmjs.com/package/esbuild-pug)
[](https://www.npmjs.com/package/esbuild-pug)
## Features
- Compiles `.pug` and `.jade` files
- Supports various configuration file formats
- Integrates with esbuild seamlessly## Installation
```sh
npm install --save-dev esbuild-pug
```### Usage
```ts
import { build } from 'esbuild';
import { pugPlugin } from 'esbuild-pug';build({
entryPoints: [ 'app.js' ],
bundle: true,
outfile: 'out.js',
plugins: [ pugPlugin() ],
})
.catch(() => process.exit(1));
```## Configuration
You can configure the plugin by passing options:
```ts
pugPlugin({
basedir: './src/',
// other pug options
})
```### Options
You can configure your project to pass the additional options.
The plugin accepts all standard Pug options, plus:
* `root`: Set the root directory for resolving includes and extends.
* `loader`: Choose between `text` (default) or `js` output.You can see the [supported options here](https://pugjs.org/api/reference.html).
### Configuration File Formats
esbuild-pug supports configuration files in several formats:* **JavaScript** - use `.pugrc.js` or `pug.config.js` and export an object containing your configuration.
* **YAML** - use `.pugrc`, .`pugrc.yaml` or `.pugrc.yml` to define the configuration structure.
* **JSON** - use `.pugrc.json` to define the configuration structure.
* **package.json** - create an `pugConfig` property in your `package.json` file and define your configuration there.If there are multiple configuration files in the same directory, esbuild-pug will only use one. The priority order is as follows:
1. `package.json`
2. `.pugrc`
3. `.pugrc.json`
4. `.pugrc.yaml`
5. `.pugrc.yml`
6. `.pugrc.js`
7. `.pugrc.cjs`
8. `pug.config.js`
9. `pug.config.cjs`### Using Configuration Files
Here's an example configuration file that sets Pug `basedir` option (again, [see whole list of supported options here](#options)):
* `.pugrc.json` (JSON)
```json
{
"basedir": "./src/"
}
```* `.pugrc` (YAML)
```yaml
basedir: ./src/
```* `pug.config.js` (JavaScript)
```js
module.exports = {
basedir: './src/'
};
```**P.S.**: Either of that should work. No need to create all of them. [See Configuration File Formats](#configuration-file-formats).
## Build
Run `npm run build` to build the project. The build artifacts will be stored in the `dist/` directory.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.