{"id":1225,"date":"2013-07-26T12:14:14","date_gmt":"2013-07-26T18:14:14","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/?p=1225"},"modified":"2013-07-23T14:55:16","modified_gmt":"2013-07-23T20:55:16","slug":"platform-specific-cssjavascript-with-cordova-cli","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/1225","title":{"rendered":"Platform Specific CSS\/Javascript with Cordova CLI"},"content":{"rendered":"<p>Cordova CLI has a really good setup for merging in content that is platform specific under the <code>www<\/code> directory.  <\/p>\n<p>Basically, under the <code>merges<\/code> directory, you can place platform specific directories; mimic the names under <code>platforms<\/code>.  Under that you can create directories named the same as directories under <code>www<\/code>&#8212;<code>css<\/code>or <code>js<\/code>, for example, and the files under those directories will be copied to the <code>platforms<\/code> build directories by the <code>cordova prepare<\/code> command.<\/p>\n<p>The <code>merges<\/code> directory is useful, but limited.  <\/p>\n<p>When we had a Cordova app mocked up by a <a href=\"http:\/\/cloudfour.com\/\">great phonegap consultancy<\/a>, the end deliverable included large chunks of common css, but some platform specific CSS.  Cordova CLI has no issue with this.  Another use case would be presenting a common interface for plugins for different platforms that have slightly different APIs&#8211;you can write platform specific <a href=\"http:\/\/en.wikipedia.org\/wiki\/Adapter_pattern\">adapter<\/a> objects, and place the platform specific javascript into <code>merges<\/code>.  Here&#8217;s an <a href=\"http:\/\/photokandy.tumblr.com\/post\/47426024187\/cordova-cli-simple-hooks-and-merges\">article<\/a> about another purpose for merges.<\/p>\n<p><code>merges<\/code> are limited, because only directories under <code>www<\/code> is merged.  If there is anything else you want to modify that is outside of that directory (like, say, <code>AndroidManifest.xml<\/code>), well, you are out of luck.<\/p>\n<p>Luckily, <a href='\/wordpress\/archives\/1197'>hooks<\/a> come to the rescue again.  In the next post, I will discuss how to update platform specific files using Cordova CLI.<\/p>\n<p><a href=\"http:\/\/eepurl.com\/BHYJ9\">Subscribe to my infrequent Cordova newsletter<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cordova CLI has a really good setup for merging in content that is platform specific under the www directory. Basically, under the merges directory, you can place platform specific directories; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64,7,60],"tags":[],"class_list":["post-1225","post","type-post","status-publish","format-standard","hentry","category-cordova-cli","category-mobile-technology","category-phonegap"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/1225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1225"}],"version-history":[{"count":8,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/1225\/revisions"}],"predecessor-version":[{"id":1288,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/1225\/revisions\/1288"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}