All Projects → yibn2008 → fast-css-loader

yibn2008 / fast-css-loader

Licence: MIT license
blazingly fast css loader for webpack

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to fast-css-loader

hotstuff
🔥 Composable, incremental, turnkey document compiler
Stars: ✭ 19 (-9.52%)
Mutual labels:  blazingly-fast
react-redux-semantic-ui
A starter boilerplate for a universal webapp using react, redux, express and feathers with Semantic UI theme
Stars: ✭ 39 (+85.71%)
Mutual labels:  css-loader
indexed-cache
A tiny Javsacript library for sideloading static assets on pages and caching them in the browser's IndexedDB for longer-term storage.
Stars: ✭ 56 (+166.67%)
Mutual labels:  css-loader
async
A lightweight and high performance async CSS and script loader for frontend optimization.
Stars: ✭ 17 (-19.05%)
Mutual labels:  css-loader
image-sprite-webpack-plugin
A webpack plugin that generates spritesheets from your stylesheets.
Stars: ✭ 27 (+28.57%)
Mutual labels:  css-loader
Gitoxide
An idiomatic, lean, fast & safe pure Rust implementation of Git
Stars: ✭ 2,696 (+12738.1%)
Mutual labels:  blazingly-fast

fast-css-loader

Blazingly fast css loader for webpack (about 10 times faster than css-loader when process large css files)

install

npm install fast-css-loader --save-dev

VS css-loader

fast-css-loader has higher performance when processing large css files, here is an example when process a 24200+ lines css file:

-------------------------------------
       CSS_LOADER COST: 1644 ms
  FAST_CSS_LOADER COST: 116 ms
-------------------------------------

image

Why faster?

fast-css-loader rewrites resolving parts of @import and url(...) with RegExp and some tricks, it's extramely faster than postcss used by css-loader.

Limitations

Compare with css-loader, fast-css-loader has these limitations:

  • doesn't support sourceMap
  • doesn't support minimize (you can minimize css with mini-css-extract-plugin)
  • doesn't support camelCase option
  • doesn't support css module

If you really need these features, just use original css-loader :)

Usage

just like css-loader:

module.exports = {
  module: {
    rules: [
      {
        test: /\.(svg|bmp|gif|png|jpe?g)$/,
        loader: require.resolve('file-loader'),
        options: {
          name: '[name].[hash:8].[ext]'
        }
      },
      {
        test: /\.css$/,
        use: [
          'style-loader',
          'fast-css-loader'   // replace you css-loader with fast-css-loader
        ]
      },
    ]
  }
}

Options

Name Type Default Description
root {String} / Path to resolve URLs, URLs starting with / will not be translated
url {Boolean} true Enable/Disable url() handling
alias {Object} {} Create aliases to import certain modules more easily
import {Boolean} true Enable/Disable @import handling
importLoaders {Number} 0 Number of loaders applied before CSS loader

The above listed options are consistent with css-loader, for more detail please refer to css-loader options

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].