Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation, update example? #233

Open
tamusjroyce opened this issue Feb 21, 2023 · 1 comment
Open

Documentation, update example? #233

tamusjroyce opened this issue Feb 21, 2023 · 1 comment

Comments

@tamusjroyce
Copy link

tamusjroyce commented Feb 21, 2023

const inliner = require('inliner');
const fs = require('fs');
const path = require('path');

const htmlFilePath = fs.existsSync(fs.existsSync('./dist/index.html')) ? './dist/index.html' : './src/renderer/dist/index.html';
const inlineFilePath = fs.existsSync(fs.existsSync('./dist/index.html')) ? './dist/inline.html' : './src/renderer/dist/inline.html';

const inlined = new inliner(htmlFilePath, undefined, (err, html) => {
    fs.writeFileSync(path.resolve(path.join(process.cwd(), inlineFilePath)), html, 'utf8');
    console.log('done');
});
inlined.promise.then((html) => {
    // Why is html undefined?
    console.log('promise completed');
});

Options seem to come before the callback
Could you support inlined.promise returning html as well?

I'm not sure why. But when I run npx run inliner ./index.html >> ./inline.html I get an empty ./inline.html file. I am running in powershell (vscode on windows. meh.) and node 14.x. Not quite sure why async is returning early.

Otherwise, this works great! Thank you!

@tamusjroyce
Copy link
Author

My use case: Inline Angular so it can be pre-loaded in puppeteer. When a request comes in through express endpoint, the browser will already be preloaded.

And I could do a bunch of sheet and javascript imports. But it is nicer, repeatable, and secure (I can remove --no-sandbox) if everything is just inlined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant