Saturday, 27 May 2017

Compile LESS in Node.js & React.js

Is there a way to automatically compile LESS in React.js?

I've installed it according to the docs

I know it's possible to use the lessc command, but it seems tedious to run that command manually everytime the less is updated.

I've tried this one too, but it doesn't work:

import React, {Component}  from 'react';
import ReactDOM from "react-dom";

var less = require('less');
var lessCss = require('./app.less');

console.log(lessCss); //output: /static/media/app.725ced4d.less

less.render(lessCss, function (e, output) {
    console.log(e); //output: Unrecognized Input
    console.log(output); //output: undefined
});

class Main extends Component {
    /* render functions */



via PPG

No comments:

Post a Comment