breezewish / express-minify

Automatically minify and cache your javascript and css files.
https://npmjs.org/package/express-minify
MIT License
86 stars 18 forks source link

Support for `@import` ? #18

Closed Martii closed 7 years ago

Martii commented 9 years ago

Hello again. This is going to be a bit tricky to explain but I will give it a go in a reduced test case form...

someSnippet.js

var express = require('express');
var minify  = require('express-minify');

var app = express();

/*
 * Bunch of other express specific intialization and then...
 */
express.static.mime.define({
  'text/less': ['less']
});

/*
 * Use minify
 */
app.use(minify());

someSnippet.html

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

source1.less

@import 'source2.less';

body {
  background-color: @my-color;
}

source2.less

@my-color: #ABC123;

Produces the following output at our http://localhost:8080/source1.less:

{"type":"File","filename":"input","index":0,"line":1,"callLine":null,"column":0,"extract":[null,"@import 'source2.less';",""],"message":"'source2.less' wasn't found. Tried - source2.less,source2.less"}

... instead of the expected ...

body{background-color:#abc123}
  1. Did I do something incorrectly with express-minify initialization?
  2. Do you support the @import statement? Currently we are using the less-middleware package to achieve support.
  3. If you do support the @import statement we are going to need some exposure to the paths option in less too probably similar to #15 e.g. we currently pick through a series of .less files at different paths in our project tree and import them into our own .less from a different path.

As long as we don't use the @import statement and keep all variables and mixins in the same file express-minify works with less parsing and compiling... however splitting them out doesn't seem to.

Any help would be greatly appreciated.

breezewish commented 9 years ago

Actually this is a hard problem, cause we don't know what is the FileSystem location only based on req. Any ideas?

breezewish commented 8 years ago

New ideas: allowing users to specify a LESS instance so that he/she can get control with the working directory configurations.

breezewish commented 7 years ago

You can specify LESS options now.