inline-css
inline-css copied to clipboard
external css
Hello.
May be i misunderstood something, but,
is there any solution to make it work with external css , i mean
<link rel="stylesheet" href="./style.css" />
Because if i have many templates , i don't want to copy/paste
Thanks in advance
You have to use the url config property.
// import or require fs/promises + other modules
const baseUrl = url.pathToFileURL(__dirname + path.sep).toString();
(async () => {
const htmlFile = path.join(__dirname, 'index.html');
const html = await fs.readFile(htmlFile, { encoding: 'utf-8' });
const body = await inlineCss(
`<link href="./style.css" type="text/css" rel="stylesheet">${html}`,
{ url: baseUrl },
);
console.log(body);
})();