Skip to content

Commit

Permalink
Refactor prefix option
Browse files Browse the repository at this point in the history
  • Loading branch information
thgh committed Dec 22, 2019
1 parent 64ec72e commit 151d3f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to `rollup-plugin-scss` will be documented in this file.

## [Unreleased]

## [2.1.0] - 2019-12-22
### Added
- Add `prefix` option @jackprosser

## [2.0.0] - 2019-12-22
### Changed
- Add `node_modules/` in includePaths by default
Expand All @@ -14,7 +18,8 @@ All notable changes to `rollup-plugin-scss` will be documented in this file.
### Update
- Update `ongenerate` to `generateBundle`

[Unreleased]: https://github.com/thgh/rollup-plugin-scss/compare/v2.0.0...HEAD
[Unreleased]: https://github.com/thgh/rollup-plugin-scss/compare/v2.1.0...HEAD
[2.1.0]: https://github.com/thgh/rollup-plugin-scss/compare/v2.0.0...v2.1.0
[2.0.0]: https://github.com/thgh/rollup-plugin-scss/compare/v1.0.0...v2.0.0
[1.0.0]: https://github.com/thgh/rollup-plugin-scss/compare/v0.0.1...v1.0.0
[0.0.1]: https://github.com/thgh/rollup-plugin-scss/releases
8 changes: 4 additions & 4 deletions index.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default function css (options = {}) {
let dest = options.output

const styles = {}
const prefix = options.prefix ? options.prefix + '\n' : ''
let includePaths = options.includePaths || ['node_modules/']
includePaths.push(process.cwd())

Expand All @@ -15,11 +16,10 @@ export default function css (options = {}) {
if (scss.length) {
includePaths = includePaths.filter((v, i, a) => a.indexOf(v) === i)
try {
const cssOptions = Object.assign({
const css = require('node-sass').renderSync(Object.assign({
data: prefix + scss,
includePaths
}, options);
cssOptions.data = options.prefix ? options.prefix + scss : scss;
const css = require('node-sass').renderSync(cssOptions).css.toString()
}, options)).css.toString()
// Possibly process CSS (e.g. by PostCSS)
if (typeof options.processor === 'function') {
return options.processor(css, styles)
Expand Down

0 comments on commit 151d3f3

Please sign in to comment.