Express.js smaller compiler: unable to get work

app.js:

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

In my view of jade:

link(rel="stylesheet", type="text/css", href='/app/stylesheets/app.less)

I have fewer files: public / application / styles / app.less

When I request the page I got in the html header:

<link href="/app/stylesheets/app.less" type="text/css" rel="stylesheet">

And note in the server console.

1) So why doesn't express even try to compile app.less? Should he?

2) If everything is correct: you need to connect in htm be

<link href="/app/stylesheets/**app.less**" ... >

or should the expression change the file extension during rendering?

<link href="/app/stylesheets/**app.css**" ... >

?

+5
source share
2 answers

It seems that the compiler () has been removed from the connection and it will no longer be supported, according to TJ Holowaychuck (creator of Connect and Express):

https://github.com/visionmedia/express/issues/877


Update 2013-01-16

Express 3.0, less-middleware compiler, Connect. , .

, less-middleware package.json npm install, :

app.use(require('less-middleware')({ src: __dirname + '/public' }));
app.use(express.static(path.join(__dirname, 'public')));

Jade CSS:

link(rel='stylesheet', type='text/css', href='css/styles.css')

:

myapp
+-public
  +-css
    +-styles.less

less-middleware , .css . , CSS.

, CSS . Git, .css .gitignore .

+12

LESS , , Stylus.

: , [pull request] [0] LESS, .

LESS.js:

var lessMiddleware = require('less-middleware');

var app = express.createServer();

app.configure(function () {
    // Other configuration here...

    app.use(lessMiddleware({
        src: __dirname + '/public',
        compress: true
    }));

    app.use(express.static(__dirname + '/public'));
});

css:

link(rel="stylesheet", type='text/css', href='/app/stylesheets/app.css')
+5

All Articles