Skip to content

Instantly share code, notes, and snippets.

@benkeen
Last active September 16, 2015 12:19
Show Gist options
  • Save benkeen/b4fb8748c6a3f5e90cdc to your computer and use it in GitHub Desktop.
Save benkeen/b4fb8748c6a3f5e90cdc to your computer and use it in GitHub Desktop.
Current situation
-----------------
Two scripts have special treatment in grunt to allow them to work in local + prod:
Ace
- referenced as a requireJS dependency and thus included in the require.js bundle.
- The Ace themes + modes AREN'T, however & therefore copied over manually by grunt.
- they're copied to an /ace subfolder. I think the subfolder is needed because of
the "ace/ace" use as the requireJS name. see:
https://github.com/apache/couchdb-fauxton/blob/master/app/addons/components/react-components.react.jsx#L18
[I don't think that may be necessary, but whatever...]
Zeroclipboard
- JS is referenced as a requireJS dependency and thus included in the require.js bundle.
- the swf file is NOT referenced, but loaded dynamically at runtime. Like papaparse,
the script works by needing a reference to the file.
- copied over by grunt to a js/zeroclipboard folder for prod
- initialize.js is generated to contain am app.zeroclipboardPath value, used by the script
to know where to find the swf.
_______________________________
Now papaparse!
Suggestion:
1. change initialize.js to include an app.bundled = true/false param. That would obviously be set to
true for prod environments, false for others (where it's not bundled)
2. add a new "magic" folder name in addons, like: /app/addon/[addonName]/dependencies (better name? "external" is taken)
3. Update grunt to automatically copies over anything in that folder into a /js/[addonName] folder.
Then, the runtime code will always know where to find it, based on the app.bundled setting.
Benefits:
- it'll work for any addons here on out & we won't need to keep hacking the gruntfile
- we could refactor Zeroclipboard to use this as well & drop the hardcoded stuff in the grunt file for that
- I *think* I could make this work for Ace as well, but don't quote me.
@michellephung
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment