Skip to content

wrap css classes with namespaces with this loader for webpack

License

Notifications You must be signed in to change notification settings

Y-Sree-Chaitanya/wrap-css-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

wrap-css-loader

CSS Wrap Loader for webpack.

Uses loader-utils.getOptions() to get the options, hence avoids any depreciation warnings related to parseQuery().

Install

npm install wrap-css-loader --save-dev

Usage

Basic Usage
module.exports = {
  /* webpack config */
  module: {
    loaders: [{
     test: /\.css$/,
      loader: "wrap-css-loader",
      options: {
        selector: "namespace"
      }
    },
    //other loaders
  ]},
}

Example with a typical webpack config using babel-loader, sass-loader and extract text plugin.

module.exports = {
  /* Webpack config */
  module: {
    loaders: [{
      test: /\.js$/,
      exclude: /node_modules/,
      loader: 'babel-loader'
    },
    {
      test: /\.(sass|scss)$/,
      loader: ExtractTextPlugin.extract({
        use: [
          {
            loader: "css-loader",
            options: {
              sourceMap: true
            }
          },
          {
            loader: "wrap-css-loader",
            options: {
              selector: config.namespace
            }
          },          
          {
            loader: "sass-loader",
            options: {
              sourceMap: true
            }
          },
        ]
      })
    },
  ]},
  
plugins: [
    new ExtractTextPlugin('[name].css'),
  ],
}

About

wrap css classes with namespaces with this loader for webpack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published