A broken @import in .less file causes compilation to fail silently in run-app #32

Open
pelamfi opened this Issue Jun 28, 2012 · 1 comment

2 participants

@pelamfi

It seems that problems in processing of @import causes the .less file to appear as a less file
instead of .css file in the page header while no errors or warnings appear.

Below are the steps to reproduce the bug with missing @import file.

grails create-app lesscssbugtest
cd lesscssbugtest
cat ../lesscssbugtest.diff | patch -p1 -F3 -l
grails run-app

Here is lesscssbugtest.diff:

diff -Nru lesscssbugtest.clean/grails-app/conf/ApplicationResources.groovy lesscssbugtest/grails-app/conf/ApplicationResources.groovy
--- lesscssbugtest.clean/grails-app/conf/ApplicationResources.groovy    2012-05-23 08:01:26.000000000 +0300
+++ lesscssbugtest/grails-app/conf/ApplicationResources.groovy  2012-06-28 15:58:43.393737726 +0300
@@ -2,4 +2,7 @@
     application {
         resource url:'js/application.js'
     }
+    test {
+   resource url:'/less/test.less'
+    }
 }
\ Ei rivinvaihtoa tiedoston lopussa
diff -Nru lesscssbugtest.clean/grails-app/conf/BuildConfig.groovy lesscssbugtest/grails-app/conf/BuildConfig.groovy
--- lesscssbugtest.clean/grails-app/conf/BuildConfig.groovy 2012-05-23 08:01:32.000000000 +0300
+++ lesscssbugtest/grails-app/conf/BuildConfig.groovy   2012-06-28 15:24:30.785861534 +0300
@@ -39,7 +39,8 @@
     plugins {
         runtime ":hibernate:$grailsVersion"
         runtime ":jquery:1.7.1"
-        runtime ":resources:1.1.6"
+        runtime ":resources:1.2-RC1"
+        runtime ":lesscss-resources:1.3.0.3"

         // Uncomment these (or add new ones) to enable additional resources capabilities
         //runtime ":zipped-resources:1.0"
diff -Nru lesscssbugtest.clean/grails-app/views/layouts/main.gsp lesscssbugtest/grails-app/views/layouts/main.gsp
--- lesscssbugtest.clean/grails-app/views/layouts/main.gsp  2012-05-23 08:01:32.000000000 +0300
+++ lesscssbugtest/grails-app/views/layouts/main.gsp    2012-06-28 15:30:36.363404846 +0300
@@ -14,6 +14,7 @@
        <link rel="apple-touch-icon" sizes="114x114" href="${resource(dir: 'images', file: 'apple-touch-icon-retina.png')}">
        <link rel="stylesheet" href="${resource(dir: 'css', file: 'main.css')}" type="text/css">
        <link rel="stylesheet" href="${resource(dir: 'css', file: 'mobile.css')}" type="text/css">
+                <r:require modules="test"/>
        <g:layoutHead/>
         <r:layoutResources />
    </head>
diff -Nru lesscssbugtest.clean/web-app/less/test.less lesscssbugtest/web-app/less/test.less
--- lesscssbugtest.clean/web-app/less/test.less 1970-01-01 02:00:00.000000000 +0200
+++ lesscssbugtest/web-app/less/test.less   2012-06-28 16:18:46.637233225 +0300
@@ -0,0 +1,7 @@
+
+// comment this out to get less to compile into css again:
+@import "nonexistent";
+
+#page-body {
+  background: green;
+}

The page:
http://localhost:8080/lesscssbugtest/
then has the following line:

<link href="/lesscssbugtest/less/test.less" type="text/css" rel="stylesheet/less" media="screen, projection" />

The problem goes away and the file is converted to .less when the file in @import exists:

touch web-app/less/nonexistent.less
@manuelvio

An accidentally removed less file led me to spend half a day trying to find the cause of my app going weird.
Thank you pelamfi for opening and documenting this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment