Open dabloem opened 12 years ago
It should be able to resolve a relative path or a classpath resource. There are various related changes in the current development version so it will be good if you can build the 1.1.5-SNAPSHOT locally and try it. You can also check the tests for a reference.
I'm not sure how this can be solved in lesscss-engine context, but I can describe the solution I use in wro4j which provides a class called LessCssProcessor (similar to lesscss-engine). In order to solve the @import directive, before the LessCssProcessor is applied, another preProcessor is used (called CssImportPreProcessor) which is responsible for @import statement handling. As a result, the LessCssProcessor is applied on the entire lesscss content, rather than just on the resource containing the @import statement.
Not sure if this helps you, but at least you can try a similar approach.
Cheers, Alex
@asual , I built the app with latest 1.1.5-snapshot. The error changed a bit. as shown: org.mozilla.javascript.WrappedException: Wrapped java.io.FileNotFoundException: File not found: setting.less (/j../META-INF/less.js#2426) at com.asual.lesscss.LessEngine.parseLessException(LessEngine.java:188) The setting.less file was placed at WEB-INF/setting.less
@alexo , thanks for the suggestion. I was thinking of a similar solution. I will take a look at it and post my findings...
Are you testing this against two files which are both located in WEB-INF? In general it should work but probably JSF introduces something specific. It seems that I can only fix this if I have a sample project or test case. Alternatively you can try putting a print() tracing in the engine.js function and see if it can show you where the engine is actually looking for the file.
Hey Duncan, I am looking for exactly that: an integration of LessCss in JSF. Can you provide the sourcecode of your Resourcehandler somehow? Thanks Martin
Duncan's code is already on GitHub: https://github.com/dabloem/jsf-less-resourcehandler
I'm using this project with JSF but I configure it as a separate servlet: https://github.com/asual/lesscss-servlet
Finally is problem of imports resolved?
I believe the server side includes for JSF can be easily implemented using the changes introduced by my earlier contribution: https://github.com/asual/lesscss-engine/pull/32
What's need to be done:
com.asual.lesscss.loader.ResourceLoader
implementation that can access your templates and less stylesheets LessEngine
during initializationlocation
parameter to compile
method. The value of the parameter must be the path of the template as understood by your ResourceLoader
implementation. This will allow the relative stylesheet paths to be resolved correctly.
Hi, this is not really an issue/bug. But rather a question how to proceed.
I created a resourceHandler for JSF 2 to process/serve less files. The LessResource is accountable for serving up the compiled less resource. When using the @import directive, the engine is unable to find the file. This sounds logical, how could the LessEngine know where to find the imported resource? The error is the following: com.asual.lesscss.LessException: org.mozilla.javascript.EcmaError: TypeError: Cannot call method "replace" of undefined (/../META-INF/less.js#2517) at com.asual.lesscss.LessEngine.parseLessException(LessEngine.java:188)
Question, what is the best approach to include an imported file.
Regards, Duncan