michalkvasnicak / babel-plugin-css-modules-transform

Extract css class names from required css module files, so we can render it on server.
MIT License
326 stars 54 forks source link

transform with less #88

Closed cainiaokan closed 6 years ago

cainiaokan commented 6 years ago

The option preprocessCss only accepts a synchronized method which takes the input and synchronously generate an output. However, less compiler doesn't have a synchronized method, its render method returns a promise object instead. So embarrassed...

nross83 commented 4 years ago

I ran into this as well and decided to just use lessc manually. Here's what I did:

const lessPath = path.resolve(process.cwd(), './node_modules/.bin/lessc');

const result = spawnSync(lessPath, ['-'], {
  input: data,
  cwd: process.cwd(),
  encoding: 'utf-8',
}).stdout;

Leaving this here for others as a possible work-around.