GithubHelp home page GithubHelp logo

yangyongan / esbuild-style-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from g45t345rt/esbuild-style-plugin

0.0 0.0 0.0 351 KB

Another esbuild plugin for bundling style files. Support SASS, LESS, STYLUS and css. Handles css modules and works with server side rendering.

JavaScript 4.07% TypeScript 88.71% CSS 3.70% HTML 0.03% Less 0.73% SCSS 0.92% Sass 1.39% Stylus 0.46%

esbuild-style-plugin's Introduction

esbuild-style-plugin

Another esbuild plugin for your styling.

  • Supports multiple preprocessors like SASS, STYLUS, LESS
  • Dynamic preprocessors import - no preprocessors installed by default
  • Handles css modules automatically with PostCSS
  • You can include postcss plugins (autoprefixer, preset-env)
  • Can read postcss.config.js config file - if path is provided in postcssConfigFile option
  • Support postcss/tailwindcss dependencies for watching files - https://github.com/postcss/postcss/blob/main/docs/guidelines/plugin.md#3-dependencies
  • SSR / Server side rendering friendly :)
  • Includes d.ts files in dist
  • Build format for both cjs and esm
  • Support esbuild watch
  • Written in Typescript with maintainable code

NPM package

npm i -D esbuild-style-plugin

Using the package

Look at the test files or here is a basic example

import stylePlugin from 'esbuild-style-plugin'
//const stylePlugin = require('esbuild-style-plugin')

esbuild.build({
  plugins: [
    stylePlugin()
  ]
})

Plugin options

Preprocessor

The plugin does not come with all preprocessor installed since you might not need all of them.

Install the ones you need!

  • SASS npm i -D sass
  • LESS npm i -D less
  • STYLUS npm i -D stylus

CSS Modules

Server side rendering

A specific use case that this plugin covers is SSR. Using extract: false will not process css on server side but will keep css mapping for css modules.

PostCSS

The plugin is using PostCSS to handle css modules files. You can include any other plugins with the postcss option.

CSSNano

Do not use cssnano plugin. It won't work and if it did it minifies all files seperatly (slow not efficient). Just let esbuild minify and do his job.

Preprocessors import typings

If you want to be able to use import styles from 'styles.module.sass' without any errors Just add esbuild-style-plugin to your types in tsconfig.json

tsconfig.json import types

esbuild-style-plugin's People

Contributors

alappe avatar corrideat avatar doberkofler avatar fifv avatar fragsalat avatar g45t345rt avatar yangyongan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.