Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# esbuild PostCSS Plugin
# PostCSS esbuild plugin

[![JSR](https://jsr.io/badges/@udibo/esbuild-plugin-postcss)](https://jsr.io/@udibo/esbuild-plugin-postcss)
[![JSR Score](https://jsr.io/badges/@udibo/esbuild-plugin-postcss/score)](https://jsr.io/@udibo/esbuild-plugin-postcss)
Expand Down Expand Up @@ -34,29 +34,18 @@ This plugin can be used with the esbuild Deno loader to process CSS files during
bundling. The esbuild Deno loader is a plugin that allows esbuild to import
Deno-specific modules and handle Deno's import/export syntax.

> **Note:** The official `@luca/esbuild-deno-loader` package has compatibility
> issues with other plugins (see
> [Issue #159](https://github.com/lucacasonato/esbuild_deno_loader/issues/159)).
> Until [PR #160](https://github.com/lucacasonato/esbuild_deno_loader/pull/160)
> is merged into the official repository, it's recommended to use the
> `@kylejune/esbuild-deno-loader` fork which fixes this compatibility issue.

Below is an example of how to use this esbuild postcss plugin with the esbuild
Deno loader:

```ts
import * as esbuild from "esbuild";
import {
denoLoaderPlugin,
denoResolverPlugin,
} from "@luca/esbuild-deno-loader";
import { denoPlugin } from "@deno/esbuild-plugin";
import { postCSSPlugin } from "@udibo/esbuild-plugin-postcss";

await esbuild.build({
plugins: [
denoResolverPlugin({ configPath }),
postCSSPlugin({ modules: true }),
denoLoaderPlugin({ configPath }),
denoPlugin({ configPath }),
],
entryPoints: ["./src/main.ts"],
outdir: "./dist",
Expand All @@ -66,13 +55,12 @@ await esbuild.build({
esbuild.stop();
```

When using the esbuild Deno loader with this plugin, make sure to:

1. Put the deno resolver plugin before the PostCSS plugin in the plugins array.
2. Put the deno loader plugin after the PostCSS plugin in the plugins array.
When using the esbuild Deno loader with this plugin, make sure to put the deno
plugin after the PostCSS plugin in the plugins array.

This is needed so that your style sheets will use deno to resolve the paths to
import.
This is needed so that your esbuild entryPoints will resolve relative to
esbuild's absWorkingDir rather than relative to the directory of your deno.json
file.

For example, if you're using tailwindcss, you'd have the following import
statement in your main style sheet. It would use the tailwindcss referenced in
Expand Down
30 changes: 15 additions & 15 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@udibo/esbuild-plugin-postcss",
"version": "0.2.1",
"version": "0.3.0",
"exports": {
".": "./postcss.ts",
"./less": "./less.ts",
Expand Down Expand Up @@ -61,20 +61,20 @@
},
"nodeModulesDir": "auto",
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@std/async": "jsr:@std/async@1",
"@std/path": "jsr:@std/path@1",
"@std/testing": "jsr:@std/testing@1",
"@luca/esbuild-deno-loader": "jsr:@kylejune/esbuild-deno-loader@0.12",
"esbuild": "npm:esbuild@^0.24",
"postcss": "npm:postcss@8",
"postcss-modules": "npm:postcss-modules@6",
"sass": "npm:sass@^1.82",
"@deno/esbuild-plugin": "jsr:@deno/esbuild-plugin@^1.2.0",
"@std/assert": "jsr:@std/assert@^1.0.15",
"@std/async": "jsr:@std/async@^1.0.15",
"@std/path": "jsr:@std/path@^1.1.2",
"@std/testing": "jsr:@std/testing@^1.0.16",
"esbuild": "npm:esbuild@^0.25.12",
"postcss": "npm:postcss@^8.5.6",
"postcss-modules": "npm:postcss-modules@^6.0.1",
"sass": "npm:sass@^1.93.3",
"stylus": "npm:stylus@^0.64",
"less": "npm:less@^4.2",
"autoprefixer": "npm:autoprefixer@10",
"tailwindcss3": "npm:tailwindcss@^3.4",
"tailwindcss": "npm:tailwindcss@4",
"@tailwindcss/postcss": "npm:@tailwindcss/postcss@4"
"less": "npm:less@^4.4.2",
"autoprefixer": "npm:autoprefixer@^10.4.21",
"tailwindcss3": "npm:tailwindcss@^3.4.18",
"tailwindcss": "npm:tailwindcss@^4.1.16",
"@tailwindcss/postcss": "npm:@tailwindcss/postcss@^4.1.16"
}
}
Loading