Skip to content

Commit

Permalink
Ignore css output if it's not a string
Browse files Browse the repository at this point in the history
Fix thgh#26
Resolve thgh#37
  • Loading branch information
thgh committed Dec 22, 2019
1 parent db7a52c commit 47cb5b0
Show file tree
Hide file tree
Showing 4 changed files with 305 additions and 264 deletions.
8 changes: 6 additions & 2 deletions index.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export default function css (options = {}) {
return
}

if (typeof css !== 'string') {
return
}

if (typeof dest !== 'string') {
// Don't create unwanted empty stylesheets
if (!css.length) {
Expand Down Expand Up @@ -134,8 +138,8 @@ function getSize (bytes) {
return bytes < 10000
? bytes.toFixed(0) + ' B'
: bytes < 1024000
? (bytes / 1024).toPrecision(3) + ' kB'
: (bytes / 1024 / 1024).toPrecision(4) + ' MB'
? (bytes / 1024).toPrecision(3) + ' kB'
: (bytes / 1024 / 1024).toPrecision(4) + ' MB'
}

function ensureParentDirsSync (dir) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build": "rollup -c",
"dev": "rollup -cw",
"lint": "standard rollup.config.js index.es.js",
"fix": "standard --fix rollup.config.js index.es.js",
"test": "cd test && rm -f output.* && rollup -c && cmp output.js expected.js && cmp output.css expected.css && cd ..",
"prepare": "rollup -c"
},
Expand Down Expand Up @@ -39,6 +40,6 @@
"devDependencies": {
"rollup": "1",
"rollup-plugin-buble": "0",
"standard": "13"
"standard": "14"
}
}
5 changes: 3 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ export default {
input: 'index.es.js',
output: {
file: 'index.cjs.js',
format: 'cjs',
format: 'cjs'
},
plugins: [
buble()
]
],
external: ['fs', 'path', 'rollup-pluginutils']
}
Loading

0 comments on commit 47cb5b0

Please sign in to comment.