1.0.1 • Published 6 years ago

styleable-loader v1.0.1

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

Travis CI David npm The MIT License

NPM

styleable-loader

Webpack loader used to increase css rules specificity at build time

Install

npm i -D styleable-loader

Usage

This loader is intended to work with css-loader. Make sure styleable-loader is directly used after css-loader.

const Path = require('path');

module.exports = {
    entry: [
        './index.js'
    ],
    output: {
        path: Path.join(__dirname, 'dist'),
        filename: 'bundle.js'
    },
    resolveLoader: {
        modules: ['node_modules', './']
    },
    module: {
        rules: [
            {
                test: /\.scss$/,
                use: [
                    'style-loader',
                    'styleable-loader',
                    'css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
                    'sass-loader'
                ]
            }
        ]
    },
    resolve: {
        extensions: ['.js', '.jsx']
    },
    mode: 'development'
};

Options

NameTypeDefaultDescription
appendedSpecificityString:not(false)The selector string which is appended to every rule to increase specificity
fileNameRegexRegex/.*custom\.styles\.scss/giA regex to decide on which files this loade should be applied on

Tests

npm test