Skip to content

Commit

Permalink
feat(initial): initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
crsten committed Oct 16, 2018
1 parent aeca655 commit 80e2a54
Show file tree
Hide file tree
Showing 5 changed files with 8,362 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: node_js
cache:
directories:
- ~/.npm
notifications:
email: false
node_js:
- '10'
after_success:
- npm run travis-deploy-once "npm run semantic-release"
branches:
except:
- /^v\d+\.\d+\.\d+$/
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# sass-scope-loader

[![Build Status](https://travis-ci.org/ElderAS/sass-scope-loader.svg?branch=master&style=flat-square)](https://travis-ci.org/ElderAS/sass-scope-loader)
[![npm](https://img.shields.io/npm/dt/sass-scope-loader.svg?style=flat-square)](https://www.npmjs.com/package/sass-scope-loader)
[![npm](https://img.shields.io/npm/v/sass-scope-loader.svg?style=flat-square)](https://www.npmjs.com/package/sass-scope-loader)

Sass loader to scope styles inside selector

This plugin scopes all your styles inside a configurable selector:

```scss
//Before sass-scope-loader
.input {
//...
}

//After sass-scope-loader width options.selector ".my-plugin"
.my-plugin .input {
//...
}
```

### Installation

`npm install --save sass-scope-loader`

### Usage

```js
/* webpack.config.js */
module.exports = {
module: {
rules: [
{
test: /\.scss$/,
use: {
loader: 'sass-scope-loader',
options: {
selector: '.SCOPESELECTOR',
},
},
},
],
},
}
```

## License

[The MIT License](http://opensource.org/licenses/MIT)
Copyright (c) Carsten Jacobsen
24 changes: 24 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { getOptions } = require('loader-utils')
const validateOptions = require('schema-utils')

const schema = {
type: 'object',
properties: {
selector: {
type: 'string',
},
},
}

module.exports = function(source) {
const options = getOptions(this) || {}

if (!options.selector) {
console.error('SassScopeLoader: options.selector is required')
return source
}

validateOptions(schema, options, 'SassScopeLoader')

return `${options.selector} { ${source} }`
}
Loading

0 comments on commit 80e2a54

Please sign in to comment.