Skip to content

Express wrapper containing webpack dev middleware and hot middleware

Notifications You must be signed in to change notification settings

madole/express-dev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status npm version

##Express-Dev

An express wrapper which takes in a webpack config and returns you an express app with webpack dev middleware and webpack hot middleware in the stack.

expressDev = require 'express-dev'
config = require './config/webpack.dev.config'
app = expressDev(config)

You can add your own middlewares to this app instance just as you would with a standard express instance.

An example of it in usage within an app would look like this

JS Example

import path from 'path';
import { Router } from 'express';
import expressDev from 'express-dev';
import config from './config/webpack.dev.config';

const app = expressDev(config);
app.set('views', path.join(process.cwd(), 'src', 'views'));
app.set('view engine', 'jade');

const router = new Router();
router.get('/', (req, res, next) => res.render('index'));

app.use(router);
app.listen(3000, () => console.log('listening on port 3000'));

Coffeescript example

path = require 'path'
{Router} = require 'express' 
expressDev = require 'express-dev'
config = require './config/webpack.dev.config'

app = expressDev(config)
app.set 'views', path.join(process.cwd(), 'src', 'views')
app.set 'view engine', 'jade'

router = new Router()
router.get('/', (req, res, next) -> res.render 'index' )

app.use(router)
app.listen(3000, -> console.log 'listening on 3000')

Now you can dev your front end code with hot module reloading if it can do it, or live reloading if it cant.

About

Express wrapper containing webpack dev middleware and hot middleware

Resources

Stars

Watchers

Forks

Packages

No packages published