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

preserveMediaQueries: true still removes <styles>...</styles> from html. #88

Open
john007abhilash opened this issue Jul 15, 2019 · 1 comment

Comments

@john007abhilash
Copy link

john007abhilash commented Jul 15, 2019

In my code CSS is resolved from tag, if i place CSS in html and run, then tag are left intact, but when adding styles using tag then the styles are not resolved even though inline styles are applied, so preserveMediaQueries: true still removes styles. I am using http-server to run it, and node to create the html.

Here is the html

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <link rel="stylesheet" type="text/css" href="http://127.0.0.1:8080/styles/styles.css">
</head>

Here is the js

var inlineCss = require('inline-css');#
const fileName = 'test-inline.html'
var fs = require('fs'),
path = require('path'),
filePath = path.join(__dirname, fileName);

const inlineOptions = {
url: ' ',
preserveMediaQueries: true
};

// Read file
fs.readFile(filePath, {encoding: 'utf-8'}, function(err, html) {
if (!err) {
console.log('received html: ' + html);
// Inline css file contents to variable

    inlineCss(html, inlineOptions)
        .then((inlineHtml) => {
            console.log(inlineHtml);
            // Write inlined contents to file
            fs.writeFile('inline-' + fileName, inlineHtml, (err) => {
                if (err) {
                    return console.log(err);
                }
                console.log('write success');
            });
        });
} else {
    console.log(err);
}

});

@anhkhoi
Copy link

anhkhoi commented May 24, 2021

same issue for me

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

2 participants