5
  app.use(express.compiler({ src: __dirname + '/public', enable: ['less'] }));

That's the line in my app.js that enables less. How can I pass the { compress: true } parameter to it?

0

3 Answers 3

4

I also had this problem and thought this can be useful to share with others:

var lessMiddleware = require('less-middleware');
app.use(lessMiddleware({ src: __dirname + '/public', compress: true, optimization: 2 }));

More information and settings about the minify-process can be found in the Less-Middleware README.md

Sign up to request clarification or add additional context in comments.

Comments

2
+50

use less4clients with the compress option

I deprecated and removed the less4clients package which extends a express.js server with a less css rendering middleware to render less files to css on the fly (and cache the results in memory) in favor of a newer project of mine called DocPad that lets you use any pre-processor you want.

As of this time of writing, it does not have an easy to use express middleware like less4clients, however such a thing is on the roadmap soon. Instead you can use it standalone or via its API.

In hindsight I should have kept less4clients available and just stated in it's readme that DocPad is the new way of doing things, but I never realised less4clients was actually being used by anyone as DocPad has already gained so much attention.

2 Comments

seems that the package 'less4clients' is removed from your GitHub-account. Can you provide a new link?
@Voles I chose to deprecate less4clients in favor of DocPad, updated my answer to explain - sorry for the inconvenience!
0

Sadly, you can't and use connect's compiler to do it. The connect.compiler, which is what express.compiler is, only allows you to set which compilers to use, but not any options for the individual compilers. If you want to set less.js's compress flag you will need to create you're own middleware that user the less.js module.

1 Comment

How would I go about doing that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.