0

I have added uglifyjs plugin to my project with grails install-plugin uglify-js-minified-resources.

Also added compile ":uglify-js-minified-resources:0.1.1" to my BuildConfig.groovy file.

After starting application none of the js files was minified. Am i missing some configuration? I was following this

My BuildConfig file

grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
    // specify dependency exclusions here; for example, uncomment this to disable ehcache:
    // excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility

repositories {
    inherits true // Whether to inherit repository definitions from plugins

    grailsPlugins()
    grailsHome()
    grailsCentral()

    mavenLocal()
    mavenCentral()

    mavenRepo "xxx"

}

dependencies {
    // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.

    // runtime 'mysql:mysql-connector-java:5.1.22'
    runtime 'org.mybatis:mybatis-spring:1.0.2'
    runtime 'org.apache.poi:poi:3.9'
}

plugins {
    runtime ":hibernate:$grailsVersion"
    runtime ":jquery:1.8.3"
    runtime ":resources:1.2"
    compile ":grails-melody:1.45"
    compile ":uglify-js-minified-resources:0.1.1"

    build ":tomcat:$grailsVersion"

    runtime ":database-migration:1.3.2"

    compile ':cache:1.0.1'

    if (Environment.current == Environment.PRODUCTION) {
        runtime ':ext-js-common:latest.release'
    }
}

}

my resourses file :

modules = { 
    css {
        dependsOn 'css-common'
        resource url:'css/test.css'
    }

    utils {
        dependsOn 'ext-js-core'
        resource url:'js/util/test.js'

    }

    plugins {
        dependsOn 'ext-js-core, ext-overrides, utils, plugins-common'
        resource url:'js/plugins/asde.js'
    }

    extensions {
        dependsOn 'ext-js-core, utils, ux-common'
        resource url:'js/ux/treecombo/Ext.TreeCombo.js'

    }

    stores {
        dependsOn 'ext-js-core, utils'
        resource url:'js/store/store.js'

    }

    ui {
        dependsOn 'ext-js-core, utils, ext-overrides, plugins, extensions, stores'
        resource url:'js/ui/tab.ui.js'
    }

}

my app.gsp file contains these modules:

    <r:require module="css"/>   
<r:require module="utils"/>
<r:require module="plugins"/>
<r:require module="extensions"/>
<r:require module="stores"/>
<r:require module="ui"/>
kuldarim
  • 1,096
  • 8
  • 21
  • 44

2 Answers2

2

First make sure you have the resource plugin enabled for the environment you are checking. Many times I had it off in Dev on accident. Also you can turn on the logging to see what is happening. Add the following to your log4j config.

debug "org.grails.plugin.resource"

Also the minified resources will only show on the web page itself. And only if using the tags from the resource plugin.

Jeff Beck
  • 3,944
  • 3
  • 28
  • 45
  • Thanks, it helped me to check if it is running and yes it is. The only problem left is how could i have a look to compressed code, because in firebug i can`t see any changes or compression done. What tags should i add to only see compressed code? – kuldarim Nov 11 '13 at 06:16
  • Use in the gsp and you define modules in config or resource.groovy – Jeff Beck Nov 11 '13 at 12:36
  • i don`t use jquery-ui, so that module cannot be found. Maybe you know module name for uglifyjs only? – kuldarim Nov 11 '13 at 13:09
  • What modules have you configured in the resource plugin? You may want to go through the resource plugin doc to make sure you have it all correct. – Jeff Beck Nov 11 '13 at 13:14
  • What module should i add to make it work? Because i have just configured my *.js files and thats all. – kuldarim Nov 11 '13 at 13:18
  • What ever module you put your JS files in. – Jeff Beck Nov 11 '13 at 14:39
  • Check my updated, i added those files to my question – kuldarim Nov 12 '13 at 06:51
  • Adding that tag should be working for you, are you getting any errors in the logs? – Jeff Beck Nov 12 '13 at 06:58
  • No errors, `Uglified javascript file [main.js] to [main.min.js] in 0.184 seconds. Reduced size by 33%` are returned for all js files. But in firebug files are showed as not minified. – kuldarim Nov 12 '13 at 07:19
  • Did you end up finding a solution? – Jeff Beck Nov 12 '13 at 15:42
  • 1
    yes, `grails.resources.debug = true` in my `Config.groovy` was the reason why i was not seeing those files uglified. Thanks for help – kuldarim Nov 13 '13 at 08:48
0

If you want to install a plugin then you need to write it in BuildConfig.groovy.

dependencies {  
   // dependency will be here.
}
plugins {
    compile ":uglify-js-minified-resources:0.1.1"
}

Enjoy..

user1791574
  • 1,729
  • 2
  • 16
  • 30