rollup-plugin-postcss
Advanced tools
Comparing version 0.4.3 to 0.5.0
@@ -25,5 +25,3 @@ 'use strict'; | ||
var fileName = path.basename(autoDest, path.extname(autoDest)); | ||
var cssOutputDest = manualDest ? | ||
manualDest : | ||
path.join(path.dirname(autoDest), fileName + '.css'); | ||
var cssOutputDest = manualDest ? manualDest : path.join(path.dirname(autoDest), fileName + '.css'); | ||
var css = source.content.toString('utf8'); | ||
@@ -39,5 +37,3 @@ var promises = []; | ||
if (sourceMap === 'inline') { | ||
css += '\n/*# sourceMappingURL=data:application/json;base64,' + | ||
Buffer.from(map, 'utf8').toString('base64') + | ||
' */'; | ||
css += "\n/*# sourceMappingURL=data:application/json;base64," + (Buffer.from(map, 'utf8').toString('base64')) + "*/"; | ||
} else { | ||
@@ -59,3 +55,3 @@ css += "\n/*# sourceMappingURL=" + fileName + ".css.map */"; | ||
var extensions = options.extensions || ['.css', '.sss']; | ||
var getExport = options.getExport || function () {}; | ||
var getExport = typeof options.getExport === 'function' ? options.getExport : false; | ||
var combineStyleTags = Boolean(options.combineStyleTags); | ||
@@ -125,2 +121,12 @@ var extract = Boolean(options.extract); | ||
.then(function (result) { | ||
var codeExportDefault; | ||
var codeExportSparse = ''; | ||
if (getExport) { | ||
codeExportDefault = getExport(result.opts.from); | ||
Object.keys(codeExportDefault).forEach(function (k) { | ||
codeExportSparse += "export const " + k + "=" + (JSON.stringify(codeExportDefault[k])) + ";\n"; | ||
}); | ||
} | ||
if (combineStyleTags || extract) { | ||
@@ -131,4 +137,5 @@ transformedFiles[result.opts.from] = { | ||
}; | ||
return { | ||
code: ("export default " + (JSON.stringify(getExport(result.opts.from))) + ";"), | ||
code: (codeExportSparse + "export default " + (JSON.stringify(codeExportDefault)) + ";"), | ||
map: {mappings: ''} | ||
@@ -139,6 +146,4 @@ }; | ||
return { | ||
code: ("export default " + injectFnName + "(" + (JSON.stringify(result.css)) + "," + (JSON.stringify(getExport(result.opts.from))) + ");"), | ||
map: options.sourceMap && result.map ? | ||
JSON.parse(result.map) : | ||
{mappings: ''} | ||
code: (codeExportSparse + "export default " + injectFnName + "(" + (JSON.stringify(result.css)) + "," + (JSON.stringify(codeExportDefault)) + ");"), | ||
map: options.sourceMap && result.map ? JSON.parse(result.map) : {mappings: ''} | ||
}; | ||
@@ -145,0 +150,0 @@ }); |
{ | ||
"name": "rollup-plugin-postcss", | ||
"version": "0.4.3", | ||
"version": "0.5.0", | ||
"description": "Seamless integration between Rollup and PostCSS", | ||
@@ -38,4 +38,4 @@ "main": "dist/index.common.js", | ||
"jsdom": "^9.2.1", | ||
"postcss-modules": "^0.6.4", | ||
"postcss-nested": "^1.0.0", | ||
"postcss-modules": "^0.7.0", | ||
"postcss-nested": "^2.0.2", | ||
"require-from-string": "^1.1.0", | ||
@@ -46,3 +46,3 @@ "rimraf": "^2.6.1", | ||
"stylus": "^0.54.5", | ||
"sugarss": "^0.2.0", | ||
"sugarss": "^1.0.0", | ||
"xo": "^0.18.1" | ||
@@ -53,3 +53,3 @@ }, | ||
"fs-extra": "^3.0.1", | ||
"postcss": "^5.0.12", | ||
"postcss": "^6.0.1", | ||
"rollup-pluginutils": "^2.0.1", | ||
@@ -56,0 +56,0 @@ "style-inject": "^0.1.0" |
@@ -91,3 +91,10 @@ # rollup-plugin-postcss | ||
``` | ||
You also can import only a specific CSS className like this: | ||
```js | ||
import {className} from './style.css'; | ||
console.log(className); // .className_echwj_2 | ||
``` | ||
### Extract CSS | ||
@@ -94,0 +101,0 @@ |
12258
145
169
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedpostcss@6.0.23(transitive)
+ Addedsupports-color@5.5.0(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedchalk@1.1.3(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-flag@1.0.0(transitive)
- Removedjs-base64@2.6.4(transitive)
- Removedpostcss@5.2.18(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.03.2.3(transitive)
Updatedpostcss@^6.0.1