CSS is not applied correctly when running on node.js
See original GitHub issue- Maizzle Version: 3.5.0
- Node.js Version: 15.0.1
Hello,
Instead of using the CLI, I tried to run with node.js according to the document found here:
https://maizzle.com/docs/nodejs/
My HTML is a very basic html with tailwind classes, for the sake of testing lets try something like this:
<!DOCTYPE html>
<html>
<body>
<div class="text-xs m-5">test</div>
</body>
</html>
My nodejs code looks like this (ES6):
import fs from 'fs';
import Maizzle from "@maizzle/framework";
import minimist from 'minimist';
var args = minimist(process.argv.slice(2));
if (args.hasOwnProperty('in-file')) {
var inFiles = args['in-file'];
if (typeof inFiles === 'string' || inFiles instanceof String) {
inFiles = [inFiles];
}
inFiles.forEach(function (file) {
var content = fs.readFileSync(file, "utf8");
// var {html, config} = Maizzle.render(content);
Maizzle.render(content, {
maizzle: {
env: 'production',
inlineCSS: true,
removeUnusedCSS: {
removeHTMLComments: true
},
build: {
templates: {
destination: {
path: 'build_production',
},
},
},
},
tailwind: {
css: '@tailwind utilities;',
config: import('./tailwind.config.js'),
}
}).then(({html}) => console.log(html))
})
}
My tailwind.config.js looks something like this: https://raw.githubusercontent.com/maizzle/starter-litmus/master/tailwind.config.js
When I run node build.maizzle.mjs --in-file=test2.html
I get something like this:
<!DOCTYPE html>
<html>
<body>
<div>test</div>
</body>
</html>
Seems like Maizzle stripped all classes and returns the bare html?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Can not get CSS file - node.js - Stack Overflow
My app is like this : var io = require('socket.io'), url = require('url'), sys = require('sys'), express = require('express'), http=require(' ...
Read more >Can't get css files to load or javaScript to work in Node.js server.
You'll want to make sure you have the correct path to your CSS file, as well as making sure the CSS file is...
Read more >CSS doesn't load into my HTML code using NODE.js - Sololearn
CSS doesn't load into my HTML code using NODE.js. When i read files from node js its not reading css files. and also...
Read more >Handling common JavaScript problems - MDN Web Docs
Basic syntax and logic problems (again, check out Troubleshooting JavaScript). Making sure variables, etc. are defined in the correct scope, and ...
Read more >Solving the React Error: Not Picking Up CSS Style | Pluralsight
Here, the CSS file is saved outside the src folder, so the compiler failed to import it. To make this code work, you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Updated the docs to make it clear that your template string needs to include the
{{{ page.css }}}
variable:https://maizzle.com/docs/nodejs/#example
Feel free to reopen if you still encounter issues 👍
I think Node.js document deserves some love 😄. This way of using Maizzle is super useful when integrating with other platforms since we can have more control over the code. A few things that would be cool to have:
css
config will not kick in at all right? (no compilation needed)I didn’t look much at the extend part (my fault) because I already generate the full html from another application and simply pass that string to maizzle for compilation.