diff --git a/package.js b/package.js index 03a9a6abf..2e973bdb7 100644 --- a/package.js +++ b/package.js @@ -5,10 +5,21 @@ */ var profile = (function() { - var excludes = { - 'Gruntfile': 1, - 'package': 1 - }; + //only copy files matching these expressions + //this prevents them from being evaluated as amd modules + var reCopyOnly = [ + /Gruntfile/, + /package/ + ]; + //exclude from builds completely + var reMiniExclude = [ + /Gruntfile/, + /package/ + ]; + //non-amd modules + var reNonAmd = [ + /plugins\/Google/ + ]; return { // Resource tags are functions that provide hints to the build system about the way files should be processed. // Each of these functions is called once for every file in the package directory. The first argument passed to @@ -26,15 +37,24 @@ var profile = (function() { // are typically binaries (images, etc.) and may be corrupted by the build system if it attempts to process // them and naively assumes they are scripts. copyOnly: function(filename, mid) { + for (var i = 0; i < reCopyOnly.length; i++) { + if (reCopyOnly[i].test(filename)) { + return true; + } + } return (/\/(images)\//.test(mid) && !/\.css$/.test(filename)) || - /\/node_modules\//.test(mid) || - filename in excludes; + /\/node_modules\//.test(mid); }, // Files that are AMD modules. // All JavaScript in this package should be AMD modules if you are starting a new project. If you are copying // any legacy scripts from an existing project, those legacy scripts should not be given the `amd` tag. amd: function(filename, mid) { + for (var i = 0; i < reNonAmd.length; i++) { + if (reNonAmd[i].test(filename)) { + return false; + } + } return !this.copyOnly(filename, mid) && /\.js$/.test(filename); }, @@ -42,7 +62,12 @@ var profile = (function() { // In this case, we are excluding this package configuration file which is not necessary in a built copy of // the application. miniExclude: function(filename, mid) { - return filename in excludes; + for (var i = 0; i < reMiniExclude.length; i++) { + if (reMiniExclude[i].test(filename)) { + return true; + } + } + return false; } } };