Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@frappe/esbuild-plugin-postcss2

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@frappe/esbuild-plugin-postcss2

Use postcss with esbuild

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

Looking for a maintainer!

Unfortunately I don't have time for this plugin. Please contact me if you'd like to take on this project.

esbuild-plugin-postcss2

This plugin is an optimized, type-friendly version of esbuild-plugin-postcss. It supports CSS preprocessors and CSS modules.

Install

yarn add -D esbuild-plugin-postcss2

or

npm i -D esbuild-plugin-postcss2

Usage

Add the plugin to your esbuild plugins:

const esbuild = require("esbuild");
const postCssPlugin = require("esbuild-plugin-postcss2");

esbuild.build({
  ...
  plugins: [
    postCssPlugin.default()
  ]
  ...
});

PostCSS plugins

Add your desired PostCSS plugin to the plugins array:

const autoprefixer = require("autoprefixer");

esbuild.build({
  ...
  plugins: [
    postCssPlugin.default({
      plugins: [autoprefixer]
    })
  ]
  ...
});

CSS modules

PostCSS modules are enabled by default. You can pass in a config or disable it with the modules field:

postCssPlugin.default({
  // pass in `postcss-modules` custom options
  // set to false to disable
  modules: {
    getJSON(cssFileName, json, outputFileName) {
      const path = require("path");
      const cssName = path.basename(cssFileName, ".css");
      const jsonFileName = path.resolve("./build/" + cssName + ".json");

      fs.writeFileSync(jsonFileName, JSON.stringify(json));
    }
  }
});

As per standard any file having module before the extension (ie somefile.module.css) will be treated as a module. The option fileIsModule allows to override this behavior.

postCssPlugin.default({
  // pass a custom `fileIsModule` option to tell whether a file should be treated as a module
  // in this example we want everything to be a module except file finishing with `global.css`
  fileIsModule: (filepath) => !filepath.endsWith(".global.css")
});

Preprocessors

To use preprocessors (sass, scss, stylus, less), just add the desired preprocessor as a devDependency:

yarn add -D sass

FAQs

Package last updated on 15 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc