Search code examples
grailsamazon-s3cdngrails-plugin

assets are fetched without the hash code appended while using Grails CDN Asset Pipeline Plugin


I recently configured this plugin on my project. The assets in my S3 bucket are uploaded with some random hash code appended to them. However while retrieving them the hash code are not being appended in the request. As a result it shows the resource not found error in the console. I am using Asset Pipeline 2.1.1.


Solution

  • The asset pipeline plugin adds hash value at the end of asset file name when war file is created. So run-app or prod run-app will not help you as war is not created for these commands.

    For that to work, you can use run-war or prod run-war command. Otherwise you have to create war and deploy in external tomcat.

    If you look the documentation of grails cdn asset pipeline plugin, it shows

    grails.assets.url = "https://s3.amazonaws.com/my-bucket/assets/${appName}-${appVersion}"
    

    But this should be only used for production mode but not for development mode. Example taken from asset pipeline plugin :

    environments {
        production {
            grails.assets.url = "http://s3.amazonaws.com/asset-pipe/assets/"
        }
    }