npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

simple-dev-server

v3.0.1

Published

A webpack optional dev server with proxies and mocking that requires almost no configuration.

Downloads

385

Readme

Simple Dev Server

This is a simple dev server that works with webpack apps or without webpack. It is meant to make development easier and aims to end the prickly practice of running two servers in development.

Usage

Create devserver.config.js.

module.exports = {
	proxy: {
		'/api/*': 'http://url.of.prod.api/'
	},
	publicPaths: {
		'/assets': 'assets'
	},
	mockPath: 'mock',
	app: '/index.html', // this can also be an express app
	serverConfig: {}, // config for webpack-hot-server-middleware
	port: 5450, // 3000 by default
};

All options are optional.

If you'd like to start more than one server with the same build (useful when making multiple apps) use an array of config objects instead of a single one.

If you're rendering on the server it will use webpack-hot-server-middleware to recompile your server side code. Just be sure to have a server entry in your webpack config.

Options

  • proxy - key/value pairs of URLs to servers to proxy requests. This allows you to work with an external API and/or image server.
  • publicPaths - a key/value pair of URLs to the static file directories in which they are contained.
  • mockPath - You can make a folder on your project that contains sample responses from your API calls. Paths that exist in this directory structure will be used instead of making HTTP calls.
  • app - An express app or a string that will be used to server your single page app.
  • apps - an array of apps, end with a string to serve a single page app. Ignored if app is present.
  • serverConfig - used for webpack-hot-server-middleware if there's a server entry in your webpack config.
  • port - the port number that will be used.

2. Running it

As a Project Dependency (recommended)

The recommended way is to install it as a devDependency to your project, then save it as your npm start or npm run dev script.

yarn add --dev simple-dev-server

Then add this to the "scripts" section of your package.json:

{
  "name": "YourApp",
  "scripts": {
    "start": "simple-dev-server"
  }
}

and run yarn start

As a global command

yarn global add simple-dev-server

Then you may simply run simple-dev-server

Simple Config Examples

Just Webpack (even with isomoriphic)

// Nothing. It'll default to port 3000

Serve a static directory and proxy your API and content images

module.exports = {
	proxy: {
		'/api/*': 'http://url.of.prod/',
		'/usercontent/*': 'http://url.of.prod/'
	},
	publicPaths: {
		'/assets': 'assets'
	}
};

A Webpack single page app

module.exports = {
	proxy: {
		'/api/*': 'http://url.of.prod.api/',
	},
	app: '/index.html'
};

You can have webpack serve index.html using the webpack-html-plugin, if it doesn't exist in the build it will be served statically.

Using a node app plus an index.html from the build

var app = require('./back-end-express-app');

module.exports = {
	proxy: {
		'/api/*': 'http://url.of.prod.api/',
	},
	apps: [app, '/index.html']
};