Giter Site home page Giter Site logo

lonelyhentxi / grasslands Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 86 KB

A grass wrapper with nodejs importer and an adapter between grass and sass-loader etc.

License: MIT License

Shell 0.28% TypeScript 14.68% Rust 85.04%
grass grasslands n-api napi napi-rs node-addon node-addon-api rspack rust sass

grasslands's Introduction

grasslands

https://github.com/lonelyhentxi/grasslands/actions Version GitHub License

A wrapper with nodejs import resolver and an adapter between grass and sass-loader? etc.

Performance grass is benchmarked against dart-sass and sassc (libsass) here. In general, grass appears to be ~2x faster than dart-sass and ~1.7x faster than sassc.

And In my tests, it is 5~10x faster than sass package.

Thanks to the efforts of the grass authors, this package compiles scss files much faster than the version of sass (dart-sass that compiled to js, wildly used version), and without some of the specific problems of dart-sass-embedded, such as memory leaks.

Attention

Since the current version of the origin grass has some bugs when dealing with empty argument lists for mixins and functions, and doesn't support custom importers, I'm using my own forked version of grass for now, and will switch the upstream of this package to the origin grass if it supports these capabilities in the future.

Usage

Install the package

npm install -D grasslands

Usage for sass-loader

// your other configs
{
  loader: 'sass-loader',
  options: {
    implementation: require.resolve('grasslands/lib/sass-loader-adapter'),
    sassOptions: {
      // to enable thread-loader when use old versions of sass-loader, pass a logger
      logger: {
        debug(message, _loggerOptions) {
          console.debug(message);
        },
        warn(message, _loggerOptions) {
          console.warn(message);
        },
      },
      includePaths: [
        path.resolve('your/include_paths1'),
        path.resolve('your/include_paths2')
      ],
      resolveAlias: {
        '@utils': ['src/utils']
      }
    },
  }
}
// your other configs

Currently not support sassOptions.importer/importers as it 2x ~ 4x slower.

Support

Operating Systems

node16 node18
Windows x64
Windows arm64
macOS x64
macOS arm64
Linux x64 gnu
Linux x64 musl
Linux arm64 gnu
Linux arm64 musl
FreeBSD x64

grasslands's People

Contributors

lonelyhentxi avatar

Stargazers

 avatar  avatar

Watchers

 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.