Stratosphere
Shrink wrap your dynamically generated assets. If you use tools like browserify to build your front-end code, you should consider saving the output to disk as part of your deploy process. This allows you to freeze an entire version of your app inside a container like Docker and test the release with confidence that things will not change in the future because the app was built with a different browserify version, or in a different environment.
Quick Usage
// See Full Usage for all optionsvar instance = // Save assets to diskinstance
Full Usage
var stratosphere = // app is your http server.var app = // Stratosphere optionsvar opts = // The assets you want to freeze are declared here. // Required. assets: './assets.json' // The directory where you want to save the frozen assets to. // Required. root: './assets' // This is the route that you want to serve your manifest file on. // Optional. route: 'manifest.json' // When true, will disable Stratosphere, passing all requests // straight to the app. // Default: false. disable: false // When true, will not empty the root asset directory on initialization. // Default: false. noFlush: false // Used to override manifest defaults. Default: {}. manifestOpts: version: '1.0.0' // Stratosphere wraps your server using the rules in your manifest// The callback is optional, and will be called if preload == true// when preloading is completevar instance = // The `intercept` method will modify its `request` listeners to respond// with cached data from the filesystem when possible, and return the serverinstance /** If you want to write your assets to disk** Gotcha: Calling this method on a server that is not listening on any* ports will bind it to an ephremeral one. If you plan to use the server* to handle actual requests you'll want to bind it to a port before* calling this method.*/instance /** If you want to load all assets into memory** Gotcha: Calling this method on a server that is not listening on any* ports will bind it to an ephremeral one. You almost definitely want* to call this only after binding your server to a port of your choice.*/instance // To flush the asset cache that is in memory (not the one on disk!)instance
The Assets File
You can either use a JSON file, or a .js
file that exports an array.
// If you serve lots of static assets like fonts, it might be helpful// to glob for themvar fonts = // Should export an array of strings that represent routes on the server// Routes without a leading slash will be have one added to themmoduleexports = // shorthand syntax is just a string 'app/bundle.js' // shorthand is expanded into the equivalent verbose syntax // which is useful when fine control over the manifest is desired source: '/app/bundle.js' destination: 'app/bundle.js' key: 'app/bundle.js'
The Manifest File
The manifest that Stratosphere serves is Phonegap Air compatible.