Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-devserver

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-devserver

a simple web server without caching for development

  • 0.5.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
80
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Developer Web Server

grunt-devserver provides a simple way to quickly get a development server serving up your content with

  • no caching content
  • CORS headers for cross-domain requests
  • logs requests to console
  • run from command line or Grunt 0.4.x
  • quickly configure https server

As a developer I needed a lightweight way to serve up client-side applications and content in isolation from a larger server application. Something that supported a rapid workflow and integrated with my tools.

Build Status NPM version

Installation

Install it from the command line into your project

npm install grunt-devserver --save-dev

Or add it to your package.json devDependicies

"devDependencies": {
    "grunt-devserver": "*"
}

Or install it globally

npm install grunt-devserver -g

Usage

From the Command Line

Once grunt-devserver has been installed globally you can run it from any folder by typing devserver

Command line options:

-t, --type (server type) http|https (default is http)
-p, --port (port number) listen on this port
-f, --folder (full path to a folder) serves this folder
--cache (method) the method to return in the Cache-Control HTTP header. Default is no-cache.
--file (filename) loads a json configuration file

From Grunt 0.4.x

To start a server through grunt you need a devserver configuration in your Gruntfile.js and tell grunt to load the grunt-devserver as an available task. For more information see Configuring Tasks.

    var config = {devserver: {server: {}}}
    grunt.initConfig(config)
    grunt.loadNpmTasks('grunt-devserver')

and execute using:

    grunt devserver

Now you can add the following options:

devserver: { options: { 'type' : <string> (http|https defaults to http)
                      , 'port' : <port number> (defaults to 8888)
                      , 'base' : <directory> (defaults to .)
                      , 'cache' : <string> (defaults to 'no-cache')
                      , 'httpsOptions' : <object> https.createServer options
                      , 'file' : <filename>
                      , 'async' : <boolean> (defaults to true)
                      }
           }

NOTE: Starting multiple devservers requires setting the async option to false so that other server tasks may be processed. async can also be useful when a server is needed to support integration or functional testing.

From Yeoman 1.0

Yeoman automatically loads all node_modules prefixed with "grunt" as grunt tasks. Just install grunt-devserver and add a server configuration and you're ready to go

grunt devserver

From Your Project

You can also use devserver directly as a module in your project.

    var devserver = require('grunt-devserver')
      , options = { type: "http", port: 8000 }
      , serverStarted = devserver(options)

    serverStarted.then(function(server) {
        // TODO something awesome
    })

From Intellij

As a developer tool integration is extremely important. If you are using a Jetbrains IDE like IntelliJ or WebStorm here are instructions to start a devserver directly in your IDE by adding an entry to your External Tools:

  1. Go to Preferences > External Tools
  2. Click Add
  3. Fill in the form:
    1. name: http
    2. group: devserver
    3. program: /usr/local/bin/devserver
    4. paramters: --port $Prompt$
    5. working directory: $FileDir$
  4. Hit OK. You should now be able to right-click on any folder and start your devserver!
Troubleshooting

Q: I am getting "env: node: No such file or directory"

You need to add node to your path. On a Mac 10.8.x or later see launchctl man page for more information.

  1. From a terminal run sudo vim /etc/launchd.conf
  2. Add setenv PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
  3. Reboot

Configuration

Configuration files provide you with the same functionality as provided by a grunt configuration. Since it is decoupled from GruntFile.js, configuration files can be shared easily among projects or used from the command-line.

When a property exists in the grunt/command-line configuration and in the configuration file, the grunt/command-line option always overrides the file options.

Example

A example devserverrc file

{ "options": { "type" : "http"
             , "port" : 8888
             }
}

When this file is loaded from the command-line

    devserver --file "./devserverrc" --port 4321 --cache "no-store"

The resulting configuration used by devserver

{ "options": { "type" : "http"
             , "port" : 4321
             , "cache" : "no-store"
             }
}

Contributing

There are many ways to contribute:

Anything you do can make a big difference. In smaller, open projects feedback is vital to connect the project to the community, provide more value, and encourage adoption. It's part of the feedback loop that helps make software better, faster.

When resolving issues or adding features please be sure to follow the style guide and make sure code is fully tested.

Version Notes

0.5.1

  • Fixed Express dependency version to not break task [#11][issue11]

0.5.0

  • Added grunt multitask support #8
  • Added command line multi-server configuration #9

0.4.1

  • added async configuration option

0.4.0

  • added module support #7
  • fixed an ordering issue in the middleware that was preventing index.html pages from being viewed #5

0.3.2

  • fixed an issue with case sensitive systems #6
  • added Travis-ci integration

0.3.1

  • added configuration from a file #4
  • added usage from IntelliJ instructions to README.md
  • added integration tests and e2e (end to end) grunt target for testing

0.3.0

  • added https support #2
  • conformed to the grunt options standard (breaking change)
  • added type parameter

0.2.2

  • added cache control option #1

Logos and Tools

Logos and tools are property of their respective owners.
Grunt
Yeoman

Keywords

FAQs

Package last updated on 03 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc