Skip to content

benchristel/gulp-express-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gulp 4 + Express Example

circleci badge

This repo demonstrates my current opinions on how to build an Express webapp using Gulp 4. Currently it is rather complex; expect it to get simpler as I extract reusable packages.

js-standard-style

Features:

  • Compiles ES2015 to backwards-compatible ES3. Sourcemaps included!
  • Uses Browserify to pack the tree of required files into a single, minified JS file that can be run in a browser.
  • Runs tests with Jasmine.
  • ESLint enforces Standard JS style.
  • Dependency injection with Yavanna makes unit-testing a breeze, and saves you from having to change your requires when you want to move or rename a source file.
  • The gulp watch task rebuilds the app and runs the tests and linter on every file change for the tightest possible feedback loop.

Getting Started

If you want to use this repo as a template for your own project, you can clone the latest version and reinitialize the repository:

git clone --depth=1 https://github.com/benchristel/gulp-express-example.git myproject
cd myproject
mv .git /tmp # because `rm -rf` is for crazy people
git init

Install Node via Homebrew

brew install node

Install Gulp 4

The -g flag installs the CLI globally, making the gulp executable available on your PATH.

npm install -g gulpjs/gulp-cli

Install Project Dependencies

npm install # must be run inside your project directory

Start building!

gulp watch --silent # suppress gulp output cruft

Possibly missing features

  • An option to build a production version of the app with minified browser code (I originally had uglify in the normal build pipeline, but it was too slow to use for development)
  • A version of the build pipeline that works for published NPM packages, or CLI apps.

Gotchas

  • Because of the way tests are currently run, you can't have different server and browser modules with the same name. For example, if you have a User class on the server that's a database model, you can't have a separate User class for the browser—the dependency injector will complain that you're registering two modules with the same name.

    Depending on the structure of your team, this constraint on naming may or may not be desirable. It should be possible to run the browser and server tests in separate Jasmine instances so the names don't collide, but I haven't gotten to it yet.

About

Starter kit for an Express app built with Gulp 4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published