rollup-plugin-scss
Advanced tools
Comparing version
@@ -7,2 +7,9 @@ # Changelog | ||
## [2.6.0] - 2020-08-14 | ||
### Fixed | ||
- Resolve processor as a promise during transform step @geotrev | ||
### Added | ||
- Add support for postcss processor | ||
## [2.5.0] - 2020-05-07 | ||
@@ -9,0 +16,0 @@ ### Updated |
@@ -30,3 +30,11 @@ 'use strict'; | ||
if (typeof options.processor === 'function') { | ||
return options.processor(css, styles) | ||
var processor = options.processor(css, styles); | ||
// PostCSS support | ||
if (typeof processor.process === 'function') { | ||
return Promise.resolve(processor.process(css, { from: undefined })) | ||
.then(function (result) { return result.css; }) | ||
} | ||
return processor | ||
} | ||
@@ -73,3 +81,3 @@ return css | ||
var files = Array.isArray(options.watch) ? options.watch : [options.watch]; | ||
files.forEach(function (file) { return this$1.addWatchFile(file); }); | ||
files.forEach(function (file) { return this$1.addWatchFile(file); }); | ||
} | ||
@@ -79,7 +87,6 @@ | ||
if (options.output === false) { | ||
var css = compileToCSS(code); | ||
return { | ||
return Promise.resolve(compileToCSS(code)).then(function (css) { return ({ | ||
code: 'export default ' + JSON.stringify(css), | ||
map: { mappings: '' } | ||
} | ||
}); }) | ||
} | ||
@@ -106,3 +113,3 @@ | ||
// Resolve if porcessor returned a Promise | ||
// Resolve if processor returned a Promise | ||
Promise.resolve(css).then(function (css) { | ||
@@ -109,0 +116,0 @@ // Emit styles through callback |
@@ -26,3 +26,11 @@ import { existsSync, mkdirSync, writeFile } from 'fs' | ||
if (typeof options.processor === 'function') { | ||
return options.processor(css, styles) | ||
const processor = options.processor(css, styles) | ||
// PostCSS support | ||
if (typeof processor.process === 'function') { | ||
return Promise.resolve(processor.process(css, { from: undefined })) | ||
.then(result => result.css) | ||
} | ||
return processor | ||
} | ||
@@ -67,3 +75,3 @@ return css | ||
const files = Array.isArray(options.watch) ? options.watch : [options.watch] | ||
files.forEach(file => this.addWatchFile(file)) | ||
files.forEach(file => this.addWatchFile(file)) | ||
} | ||
@@ -73,7 +81,6 @@ | ||
if (options.output === false) { | ||
const css = compileToCSS(code) | ||
return { | ||
return Promise.resolve(compileToCSS(code)).then(css => ({ | ||
code: 'export default ' + JSON.stringify(css), | ||
map: { mappings: '' } | ||
} | ||
})) | ||
} | ||
@@ -100,3 +107,3 @@ | ||
// Resolve if porcessor returned a Promise | ||
// Resolve if processor returned a Promise | ||
Promise.resolve(css).then(css => { | ||
@@ -103,0 +110,0 @@ // Emit styles through callback |
{ | ||
"name": "rollup-plugin-scss", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"description": "Rollup multiple .scss, .sass and .css imports", | ||
@@ -15,3 +15,5 @@ "main": "index.cjs.js", | ||
"test:sass": "cd test/sass && rm -f output.* && rollup -c && cmp output.js ../expected.js && cmp output.css expected.css && cd ../..", | ||
"test": "npm run test:node-sass && npm run test:sass", | ||
"test:postcss": "cd test/postcss && rm -f output.* && rollup -c && cmp output.js ../expected.js && cmp output.css expected.css && cd ../..", | ||
"test:processor": "cd test/processor && rm -f output.* && rollup -c && cmp output.js ../expected.js && cmp output.css expected.css && cd ../..", | ||
"test": "npm run test:node-sass && npm run test:sass && npm run test:processor && npm run test:postcss", | ||
"testw": "cd test/node-sass && rm -f output.* && rollup -cw; cd ..", | ||
@@ -45,2 +47,4 @@ "prepare": "rollup -c" | ||
"devDependencies": { | ||
"autoprefixer": "^9.8.6", | ||
"postcss": "^7.0.32", | ||
"rollup": "2", | ||
@@ -47,0 +51,0 @@ "rollup-plugin-buble": "0", |
@@ -83,2 +83,8 @@ # Rollup multiple .scss, .sass and .css imports | ||
// Run postcss processor before output | ||
processor: css => postcss([autoprefixer({ overrideBrowserslist: "Edge 18" })]) | ||
// Process resulting CSS | ||
processor: css => css.replace('/*date*/', '/* ' + new Date().toJSON() + ' */') | ||
// Add file/folder to be monitored in watch mode so that changes to these files will trigger rebuilds. | ||
@@ -85,0 +91,0 @@ // Do not choose a directory where rollup output or dest is pointed to as this will cause an infinite loop |
18186
8.08%310
3.33%124
5.08%6
50%