dom111 / esbuild-plugin-prettier

Allow prettier to be easily called when `watch`ing files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

esbuild-plugin-prettier

Allow prettier to be easily called when watching files in esbuild.

Usage

npm i -D esbuild-plugin-prettier
// esbuild.js
const { build } = require('esbuild'),
    // ...
    { Prettier } = require('esbuild-plugin-prettier');

build({
    // ...
    plugins: [
        // ...
        new Prettier({
            // defaults:
            write: true,
            filter: /[jt]sx?|s?css/,
            loader: (path) => path.split(/\./).pop(), 
        }),
    ],
});

Why?

I think this might be in conflict with esbuild's goals, but watch mode not running prettier for me was a little annoying, so I thought I'd explore how to write plugins in esbuild whilst solving a little annoyance I had.

About

Allow prettier to be easily called when `watch`ing files

License:MIT License


Languages

Language:TypeScript 65.1%Language:JavaScript 34.9%