question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I would love to be able to use this server sided in my esbuild setup, either as an esbuild plugin, or, preferably, as a JS api.

Something like.

const windicss = require('windicss');

const instance = windicss.createInstance({
  preflight: true,
  mode: 'compile',
... config,
});

const { html, styles } = instance.parse('<div class="rounded text-white bg-gray-400">Hello</div>');

I can already do this in tailwind by proxy of postcss but i prefer the syntax of grouping of windicss instead.

Do you foresee that this might be added?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
voorjaarcommented, May 19, 2021

Reference https://github.com/windicss/windicss/blob/main/example/interpretMode.ts

similar in js file too.

const fs = require('fs');
const { Processor } = require('windicss/lib');
const { HTMLParser } = require('windicss/utils/parser');

const html = fs.readFileSync('../test/assets/example.html').toString();

const parser = new HTMLParser(html); // Simple html parser, only has two methods.
const processor = new Processor();
const preflightSheet = processor.preflight(html); // Parse all html tags, then generate preflight

const result = processor.interpret(
  parser
    .parseClasses()
    .map((i) => i.result)
    .join(' ')
); // Combine all classes into one line to simplify operations
fs.writeFileSync(
  'interpret_test.css',
  result.styleSheet.extend(preflightSheet, false).build(false)
); // Build css, set true to minify build


1reaction
hannoerucommented, May 19, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js API
No information is available for this page.
Read more >
Node.js - RESTful API - Tutorialspoint
Node.js - RESTful API, REST stands for REpresentational State Transfer. REST is web standards based architecture and uses HTTP Protocol.
Read more >
Creating a Secure Node.js REST API - Toptal
REST APIs are so useful and ubiquitous that every web developer should know how to build them. Here's how to build a Node.js...
Read more >
How to Build REST API with Node.js from Scratch - Edureka
This article on Building a REST API with Node.js will give you a step by step demostration for creating a CRUD application using...
Read more >
What is REST API in Node.js ? - GeeksforGeeks
The API (Application Programming Interface) is a set of commands, functions, or protocols that act as an intermediary that enables two ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found