Django + Mac osx how to use less css?

2019-05-25 03:45发布

There is no less css command line compiler in mac osx. But I am trying out a project which needs to use less css.
Also less is used to compress the css files in the project. How do I handle this? I read in less website that its js can be run on a node.js server - http://lesscss.org/#-server-side-usage
But I am not understanding how to integrate it with django. What should be the value for the COMPRESS_PRECOMPILERS ?

COMPRESS_PRECOMPILERS = (                                                       
('text/less',""),                 

)

Any help appreciated from someone who has already solved this problem.

标签: css django less
2条回答
够拽才男人
2楼-- · 2019-05-25 03:58
  1. Install node.js and npm (I used homebrew to install node.js and the instructions at http://npmjs.org/ to install npm)
  2. Install the command-line less compiler with npm install --global less
  3. Add lessc to COMPASS_PRECOMPILERS (directions).

Here's the relevant snippet:

COMPRESS_PRECOMPILERS = (
    ('text/less', 'lessc {infile} {outfile}'),
)

Also, COMPRESS_PRECOMPILERS is from django_compressor, a django app, not from django itself. I think django_compressor looks quite good, but there are other options available as well.

查看更多
可以哭但决不认输i
3楼-- · 2019-05-25 04:13

Have you tried the less.app for OS X?

http://incident57.com/less/

查看更多
登录 后发表回答