3.0.14 • Published 11 days ago

a-css-loader v3.0.14

Weekly downloads
375
License
ISC
Repository
github
Last release
11 days ago

Another CSS Loader

A css loader inspired by webpack/css-loader.

Rationale

This loader is different than webpack/css-loader in the following ways.

  • Allows css-modules to be distributed and re-used as npm packages. (See webpack/css-loader#393)
  • Allows webpack to fully resolve all paths
  • Support css-modules/value (@value syntax)

TOC

Missing features

  • Source maps
  • @media queries after @imports
  • url() for @imports

Usage

Installation

$ npm install --save a-css-loader

Example

Webpack 1

// webpack.config.js

module.exports =  {
  module: {
    /* ... Omitted */
    loaders: [
      {
        test: /\.css$/,
        loader: 'a-css-loader',
        query: {
          /* These are the defaults */
          camelize: false,
          scopedNameFormat: '[local]--[hash:5]',
          mode: 'pure'
        }
      }
    ]
  }
};

CSS

/* @import will combine the css of imported files*/
@import './a-css-file';
/* @require are just an alias for @import.
They are useful when combining this loader with the sass loader because they allow you to bypass
sass's own @import
*/
@require './another-css-file';

/* These variables will be stored and exported as locals */
@value my-special-color '#ff00ff';
@value another-special-color from './colors.css';


.my-class {
  composes: another from './another-css-file.css';
  color: my-special-color;
}

JS

import cssModule from './my-css.css';

cssModule['my-special-color'] === '#ff00ff'; // true
cssModule['another-special-color'] === require('./colors.css')['another-special-color']; // true

cssModule['my-class'] === require('./another-css-file.css')['another'] + ' my-class--1a1b2'; // true

Path resolution

By default, most path references are resolved by webpack. The only exception is in url() functions. To force them to use webpack to resolve the path, prepend the path with a ~.

Example:

.my-class {
  background: url('http://not-resolved-by-webpack.com/image')
}

.my-other-class {
  background: url('~./path/resolved/by/webpack')
}

Options

NameTypeDescription
camelizebooleanWether to export camelized versions of the keys
scopedNameFormatstringFormat for class name. It leverages this.
modeenum'pure', 'global', or 'local'
3.0.14

11 days ago

4.0.0-uep1.beta.2

2 months ago

4.0.0-uep1.beta.1

2 months ago

3.0.13

9 months ago

3.0.12

10 months ago

3.0.11

12 months ago

3.0.10

1 year ago

3.0.9

1 year ago

3.0.4

2 years ago

3.0.8

1 year ago

3.0.7

2 years ago

3.0.6

2 years ago

3.0.5

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.1-alpha.502

4 years ago

1.1.1-alpha.478

4 years ago

1.1.0

5 years ago

1.0.7

5 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

1.0.0-beta.11

7 years ago

1.0.0-beta.10

7 years ago

1.0.0-beta.9

7 years ago

1.0.0-beta.8

7 years ago

1.0.0-beta.7

7 years ago

1.0.0-beta.6

7 years ago

1.0.0-beta.5

7 years ago

1.0.0-beta.4

7 years ago

1.0.0-beta.3

7 years ago

1.0.0-beta.2

7 years ago

1.0.0-beta.1

7 years ago