Saturday 6 May 2017

How to make Babel handle LESS files?

I have an isomorphic React app with server side rendering setup with NodeJS. I'm using Babel and Webpack, which work pretty fine except one problem:

Babel can't handle require('somefile.less').

For this reason I'm using Webpack to compile both backend and frontend code since Webpack has nice CSS and LESS loaders and it doesn't freak out on seeing CSS or LESS files. However, this approach comes with its own problem:

Server start time increases a lot, since webpack has to compile entire backend first.

This is fine when I'm deploying code for production, but in development environment, it's really hurting productivity.

babel-node utility, on the other hand, is super fast in comparison, if only I can make it handle CSS/LESS files. Hence my question: can we make Babel work with CSS/LESS files?



via craftsman

No comments:

Post a Comment