Giter VIP home page Giter VIP logo

spawnit's Introduction

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?

spawnit's People

Contributors

adamatri avatar tjdavenport avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

adamatri

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.