Static Resources Plugin

Introduction

Static resource management plug-in. Each module can have a "static" attribute which is an array of resources to be copied from the application path to the outputDir (or platformDir). Each static entry can be a simple string or a hash containing.

Example

{
  "platforms": ["iphone", "android"],
  "modules": {
    "foo": {
      "static": [
        // copy {app}/index.html to {outputDir}/iphone/index.html and {outputDir}/android/index.html
        "index.html",

        // copy {app}/index.html to {outputDir/index.html}
        "/index.html",

        // copy recursively {app}/static to {outputDir}/static
        "/static",

        // copy {app}/index-iphone.html to {app}/iphone/index.html only for the iphone platform
        {"src": "index-iphone.html", "dest": "index.html", "platform": "iphone"}

        // copy recursively {app}/static/iphone to {outputDir}/iphone and {app}/static/android to {outputDir}/android
        // will error if any of the platform directories are missing
        {"src": "static/$platform", "dest": "/$platform"}
      ]
   }
}

Notes

Questions

Would that mean it would get copied to {outputDir}/index.html? Instead of {outputDir}/iphone/index.html on accident?

A: No, it will go {outputDir}/iphone/index.html. Beacuse, if you have an entry that was just a string, then both src and dest are that value. The dest attribute is used to determine platformDir vs ouputDir.

If dest has a / in front of it, it will still output to the platformDir and not the outputDir if a platform is present.

A: It would copy {app}/static/iphone/ to {outputDir}/iphone/ and {app}/static/android to {outputDir}/android

(this is because the initial dest / indicates outputDir but then the platform variable is used)

Fork me on GitHub