#Inline css @imports
You have a css string with @import
statements, you want them resolved and inlined into said css string.
Code mostly adapted from the css @import
part of inliner.
Recursively inlines css imports, so works for nested @import
s too.
Still relatively early days, use with caution.
Node@^0.12
(could use earlier version if you polyfilled Promise
).
npm install --save inline-css-imports
import inlineCssImports from 'inline-css-imports'
// css -- string || css to inline imports inside
// baseUrl -- string || url where css is hosted - required to resolve relative import paths
inlineCssImports(css, baseUrl)
.then(function (updatedCss) {
console.log('I have all css @imports inlined!', updatedCss)
})
Will just remove @import
for css that doesn't exist.