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

a-css-loader

Package Overview
Dependencies
Maintainers
1
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-css-loader

> A css loader inspired by [webpack/css-loader](https://github.com/webpack/css-loader).

  • 1.0.0-beta.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.1K
increased by0.52%
Maintainers
1
Weekly downloads
 
Created
Source

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
  • Includes css-modules/values by default

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

@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 { locals } from './my-css.css';

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

locals['my-class'] === \
  require('./another-css-file.css').locals['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'

Keywords

FAQs

Package last updated on 30 Dec 2016

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