Deploying a Site
When your site has been rendered, you can select just the files and directories that are required for deployment to the live site. For security, it is recommended that you not copy the entire development directory. Rather select only the files and directories that are actually required for the live site.
One Step Deploy
$ expansive deploy
This copies the required files to the ./deploy directory. You can also specify a deploy directory on the command line. For example:
$ expansive deploy /tmp/upload
This copies the required files to the /tmp/upload directory.
Files and Directories
These are the default files and directories that expansive deploy will deploy to the ./deploy directory.
File/Directory | Contents |
---|---|
dist/ | Public web content for the site. |
package.json | The package.json file defines the ESP application name and version. |
Customizing Deployment
The deploy command can be customized via the control.deploy property in the expansive.json file. For example:
{ control: { deploy: { from: [ "dist/**", "extra/*.pdf", "cache/*.dll", "cache/*.lib", "esp.json", "package.json" ], to: "deploy", clean: true, script: '' } } }
Using control.deploy Properties
Property | Description |
---|---|
from | Array of source files. May contain wild-cards. Defaults to: ['dist/**', 'cache/*', 'package.json', 'esp.json']. |
flatten | Do not preserve source directory structure. Defaults to false. |
to | Destination directory. Defaults to ./deploy. |
clean | Remove the prior contents of the destination directory. |
script | Script to run after copying any specified files. |
Remote Deployment
You can use the deploy.script property to upload to a remote server. This example below creates a compressed tar file of the deploy contents and then uses a HTTP put request to upload to a server.
{ control: { deploy: { script: ` require ejs.tar let file = Path('upload.tgz') Tar(file).create(Path('deploy').files('**', {directories: false})) let http = Http() http.put('http://example.com/' + file, file.readString()) if (http.status != 200) { throw 'Cannot upload "' + file + '". Bad http status: ' + http.status + '.' } ` } } }