1.0.3 • Published 4 years ago
@supl.biz_tech/css-inliner v1.0.3
css-inliner
yarn add @supl.biz_tech/css-inliner
Setup
Use the provided Rollup plugin:
const { plugin } = require('@supl.biz_tech/css-inliner');
module.exports = {
// ...
plugins: [
// ...
// make sure this plugin is called last
plugin({
// optional, default: css-inliner-manifest.json
// outputFileName: 'some-manifest.json',
}),
],
};
Use the provided render
function in your SSR code:
const { render } = require('@supl.biz_tech/css-inliner');
const tags = render({
manifestPath: './build/css-inliner-manifest.json',
stylesheetPath: 'https://my-site.com/css/my-css-bundle.css',
htmlFragment: '<div>HTML generated during SSR</div>',
logError(error) {
// probably should send this error to Sentry or some alternative
console.error(error);
},
});
const pageHTML = `
<html>
<head>
...
${tags}
</head>
...
</html>
`;