0.12.0 • Published 5 years ago

spawnit v0.12.0

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

spawnit

Build Status Coverage Status

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.

Demonstration gif

CLI Options

  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

Configuration File

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: {  }
};

Custom index.html

Spawnit determines what HTML to respond with in one of two places. 1. It will look for index.html in the current working directory. 2. 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>

Roadmap

  1. Get coveralls badge working
  2. Add plugins config option to allow for complete customization of the expressjs server.
  3. Add Webdriver support?
0.12.0

5 years ago

0.11.0

5 years ago

0.10.0

6 years ago

0.9.0

6 years ago

0.8.0

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.1

6 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago