npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@luncheon/esbuild-plugin-windicss

v0.3.0

Published

An unofficial and experimental esbuild plugin for Windi CSS.

Downloads

14

Readme

esbuild-plugin-windicss

An unofficial and experimental esbuild plugin for Windi CSS.
This plugin uses @babel/parser to extract string literals from source code.

Limitations

Installation

$ npm i -D esbuild @luncheon/esbuild-plugin-windicss

Usage Example

  • build.js
const esbuild = require('esbuild')
const windiCssPlugin = require('@luncheon/esbuild-plugin-windicss')

esbuild.build({
  entryPoints: ['src/app.ts'],
  outdir: 'dist',
  bundle: true,
  minify: true,
  plugins: [
    windiCssPlugin({ windiCssConfig: { prefixer: false } }),
  ],
})
  • src/app.ts
let green = false
document.body.className = `mx-4 sm:m-auto ${green ? 'bg-green-300' : 'bg-red-300'}`

Run build.js

$ node build.js

Then two files will be output

  • dist/app.js
(()=>{var s=!1;document.body.className=`mx-4 sm:m-auto ${s?"bg-green-300":"bg-red-300"}`;})();
  • dist/app.css
.bg-green-300{--tw-bg-opacity:1;background-color:rgba(110,231,183,var(--tw-bg-opacity))}.bg-red-300{--tw-bg-opacity:1;background-color:rgba(252,165,165,var(--tw-bg-opacity))}.mx-4{margin-left:1rem;margin-right:1rem}@media (min-width: 640px){.sm\:m-auto{margin:auto}}

Options

The following are the options for this plugin and their default values.

windiCssPlugin({
  filter: /\.[jt]sx?$/,
  babelParserOptions: {
    errorRecovery: true,
    allowAwaitOutsideFunction: true,
    allowImportExportEverywhere: true,
    allowReturnOutsideFunction: true,
    allowSuperOutsideMethod: true,
    allowUndeclaredExports: true,
    tokens: true,
    plugins: ['jsx', 'typescript', 'topLevelAwait'],
  },
  windiCssConfig: undefined,
})
  • filter is an option for esbuild to narrow down the files to which this plugin should be applied.
    https://esbuild.github.io/plugins/#filters
  • babelParserOptions is passed to the @babel/parser.
    https://babeljs.io/docs/en/babel-parser
  • windiCssConfig is passed to the Windi CSS API.
    https://github.com/windicss/windicss/blob/main/src/interfaces.ts#:~:text=export%20interface%20Config

With esbuild-plugin-pipe

If you use this plugin with esbuild-plugin-pipe, pass the same plugin instance to both esbuild-plugin-pipe and esbuild.

import esbuild from 'esbuild'
import pipe from 'esbuild-plugin-pipe'
import windiCssPlugin from '@luncheon/esbuild-plugin-windicss'

const windiCss = windiCssPlugin({
  filter: /^$/,
  windiCssConfig: { prefixer: false },
})

esbuild.build({
  entryPoints: ['src/app.ts'],
  outdir: 'dist',
  bundle: true,
  minify: true,
  plugins: [
    pipe({
      filter: /\.[jt]sx?$/,
      plugins: [windiCss],
    }),
    windiCss,
  ],
})

License

WTFPL