npm Scripts
All projects must define 3 npm scripts:
build– Builds the project.start– The main task for development. Builds the project, starts a server, and watches for file changes.test– Runs the test suite. This includes unit tests and E2E tests. Ideally, for E2E tests, it should check if the server is running and either display an error message or start the server automatically.
Also consider defining scripts for:
preinstall– Useful for any pre-check tasks, e.g. making sure npm.banno-internal.com is reachable.postinstall– Useful for any one-time tasks to perform after installation, e.g. downloading SSL certificates or Selenium drivers.stop– Stops the server. (Useful for projects that start servers in a production environment.)
gulp Tasks
Very small or simple projects can use npm scripts for its tasks. Most of the time, though, you’ll want to use a task framework for writing your tasks; we use gulp.
The following conventions are recommended for your gulp tasks:
build– Compiles the project for distribution or production. These files should be compiled in or copied to adistfolder. (Note that, for library projects, compiling example apps for development or testing purposes should be handled separately, e.g.build:example.) Usually this runs thelinttask too.default– Perform “pre-publish” tasks: runslint,build, andtest.dev– To be run during development work. Compiles the project, starts a local server, and watches for changes to the files.lint– Runs linting on the project.serve– Serves the project. For library projects (e.g.helpesk-ux), a temporary folder can be used to build an example app.test– Runs all tests.test:unit– Runs the unit tests.test:e2e– Runs the end-to-end tests.watch– Watches for changes to the project files. It should re-runlint,build, andtest:unit(as needed) when files change.
The following flags should also be supported:
--env– Sets the target environment. This is mainly for development. It is usually provided by the API proxy.--mocks– Alias for--env mocks.--optimize– Turns on optimizations (module compilation, code minification, etc).