rollup-plugin-postcss
Advanced tools
Comparing version 1.5.1 to 1.6.0
@@ -0,1 +1,13 @@ | ||
## [Version 1.6.0](https://github.com/egoist/rollup-plugin-postcss/releases/tag/v1.6.0) (2018-4-17) | ||
### New features | ||
- add extensions option: [`bfec612`](https://github.com/egoist/rollup-plugin-postcss/commit/bfec612) | ||
### Bug fixes | ||
- handle importing Sass partials in node_modules: [`347d570`](https://github.com/egoist/rollup-plugin-postcss/commit/347d570) ([#90](https://github.com/egoist/rollup-plugin-postcss/issues/90)) | ||
[...full changes](https://github.com/egoist/rollup-plugin-postcss/compare/v1.5.1...v1.6.0) | ||
## [Version 1.5.1](https://github.com/egoist/rollup-plugin-postcss/releases/tag/v1.5.1) (2018-4-4) | ||
@@ -2,0 +14,0 @@ |
@@ -77,4 +77,4 @@ 'use strict'; | ||
alwaysProcess: true, | ||
test: /\.(css|sss)$/, | ||
// `test` option is dynamically set in ./loaders | ||
process({ | ||
@@ -214,2 +214,9 @@ code, | ||
const moduleRe = /^~([a-z0-9]|@).+/i; | ||
const getUrlOfPartial = url => { | ||
const parsedUrl = path.parse(url); | ||
return `${parsedUrl.dir}${path.sep}_${parsedUrl.base}`; | ||
}; | ||
const resolvePromise = pify(resolve); | ||
var sassLoader = { | ||
@@ -234,10 +241,10 @@ name: 'sass', | ||
}); | ||
resolve(url.slice(1), { | ||
const moduleUrl = url.slice(1); | ||
const partialUrl = getUrlOfPartial(moduleUrl); | ||
const options = { | ||
basedir: path.dirname(importer), | ||
extensions: ['.scss', '.sass', '.css'] | ||
}, (err, id) => { | ||
if (err) { | ||
return Promise.reject(err); | ||
} | ||
}; | ||
const finishImport = id => { | ||
done({ | ||
@@ -247,2 +254,18 @@ // Do not add `.css` extension in order to inline the file | ||
}); | ||
}; | ||
const next = () => { | ||
// Catch all resolving errors, return the original file and pass responsibility back to other custom importers | ||
done({ | ||
file: url | ||
}); | ||
}; // Give precedence to importing a partial | ||
resolvePromise(partialUrl, options).then(finishImport).catch(err => { | ||
if (err.code === 'MODULE_NOT_FOUND' || err.code === 'ENOENT') { | ||
resolvePromise(moduleUrl, options).then(finishImport).catch(next); | ||
} else { | ||
next(); | ||
} | ||
}); | ||
@@ -334,2 +357,10 @@ }].concat(this.options.importer || []) | ||
const matchFile = (filepath, condition) => { | ||
if (typeof condition === 'function') { | ||
return condition(filepath); | ||
} | ||
return condition && condition.test(filepath); | ||
}; | ||
class Loaders { | ||
@@ -349,2 +380,6 @@ constructor(options = {}) { | ||
this.loaders = []; | ||
const extensions = options.extensions || ['.css', '.sss', '.pcss']; | ||
postcssLoader.test = filepath => extensions.some(ext => path.extname(filepath) === ext); | ||
this.registerLoader(postcssLoader); | ||
@@ -378,3 +413,3 @@ this.registerLoader(sassLoader); | ||
return this.loaders.some(loader => { | ||
return loader.test && loader.test.test(filepath); | ||
return matchFile(filepath, loader.test); | ||
}); | ||
@@ -399,3 +434,3 @@ } | ||
return v => { | ||
if (loader.alwaysProcess || loader.test.test(id)) { | ||
if (loader.alwaysProcess || matchFile(id, loader.test)) { | ||
return loader.process.call(loaderContext, v); | ||
@@ -481,3 +516,4 @@ } // Otherwise directly return input value | ||
use, | ||
loaders: options.loaders | ||
loaders: options.loaders, | ||
extensions: options.extensions | ||
}); | ||
@@ -484,0 +520,0 @@ const extracted = new Map(); |
{ | ||
"name": "rollup-plugin-postcss", | ||
"version": "1.5.1", | ||
"version": "1.6.0", | ||
"description": "Seamless integration between Rollup and PostCSS", | ||
@@ -5,0 +5,0 @@ "main": "dist/rollup-plugin-postcss.cjs.js", |
@@ -90,2 +90,9 @@ # rollup-plugin-postcss | ||
### extensions | ||
Type: `string[]`<br> | ||
Default: `['.css', '.sss', '.pcss']` | ||
This plugin will process files ending with these extensions and the extensions supported by [custom loaders](#loaders). | ||
### plugins | ||
@@ -92,0 +99,0 @@ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
39754
580
300
1