Spawnit allows you to start prototyping your Javascript browser application with zero boilerplate. It will start a configurable, customizeable expressjs development server that supports live reloading, live css injection, SASS transpilation, bundling with Browserify, and script concatenation. No boilerplate is needed to start creating elaborate single page applications.
Usage: index [options]
Options:
-h, --help output usage information
-V, --version output the version number
-p, --port <n> Port number the development server will listen on.
-w, --wssPort <n> Port number the websocket server will listen on.
-e, --errorNotify Pass bundle/sass errors to desktop notifier
-n, --noOpen Do not open webpage in default browser
Spawnit will look for a spawnit-config.js
file in the current working directory. The file should export an object with configuration keys/values. All CLI options can be set in this file. Default Browserify and node-sass options can be found in ./lib
.
Example:
// spawnit-config.js
module.exports = {
port: 1337,
wssPort: 1338,
/**
* define the domain that will be used
* when the default browser is opened
*/
domain: 'localhost',
/**
* These options will be used to create a Browserify instance
*/
browserifyOpts: {},
/**
* These options will be passed to node-sass.render
*/
nodeSassOpts: {},
/**
* These options will be passed to https.createServer
*/
ssl: {
key: fs.readFileSync('./server.key'),
cert: fs.readFileSync('./server.crt'),
passphrase: 'foobarbaz',
},
/**
* Define where assets are stored and the route at which
* they will be available
*/
staticAssets: [
{ route: '/foo/bar/fonts', source: './fonts' },
],
errorNotify: false,
/**
* These scripts will be made available under /_spawnit/script/... routes
*/
scripts: [],
noOpen: false,
/**
* These files/folders will be watched. Changes will trigger css injection.
*/
scssFiles: [
path.join(process.cwd(), 'styles.scss'),
path.join(process.cwd(), 'styles'),
],
/**
* Define linting rules for `eslint`
* The ESLint::CLIEngine is being used to provide linting.
* see the CLIEngine API documentation here:
* https://eslint.org/docs/developer-guide/nodejs-api#cliengine
*/
esLintOpts: { }
};
Spawnit determines what HTML to respond with in one of two places.
- It will look for
index.html
in the current working directory. - If no index exists in the current working directory, it will use the hardcoded default,
Spawnit assumes that you're developing an SPA, so the default body only contains a single div element: <div id="app"></div>
. If you decide you need more control of the index file, be sure to include the following tags so everything still works:
<!-- this will load rendered css from the server -->
<link id="_spawnitcss" rel="stylesheet" href="/_spawnit/css">
<!-- This will be replaced by script tags that correspond to elements in the scripts option. -->
<%= scriptTags %>
<!-- this will load the compiled Browserify bundle -->
<script src="/_spawnit/bundle"></script>
<!--
this will establish a websocket connection with the Spawnit server,
allowing the utility features (live reload etc) to work
-->
<script src="/_spawnit/remote"></script>
- Get coveralls badge working
- Add plugins config option to allow for complete customization of the expressjs server.
- Add Webdriver support?