Skip to content

Commit

Permalink
add server gulp task to run a webserver
Browse files Browse the repository at this point in the history
  • Loading branch information
huguangju committed Dec 29, 2015
1 parent c0d3479 commit 7b8e784
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,5 @@ Use this markup for a quick demo
### __Running / Development__

* open ```docs/index.html``` in browser

> Or you can use `gulp server` and visit `http://localhost:8080` in Chrome browser, to avoid `XMLHttpRequest Cross origin requests` error.
14 changes: 13 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var browserSync = require('browser-sync');

/**
* Run a webserver (with LiveReload)
*/
gulp.task('server', function() {
plugins.connect.server({
root: '.',
fallback: './index.html',
port: 8080,
livereload: true
});
});

/**
* Keep multiple browsers & devices in sync when building websites.
*/
Expand Down Expand Up @@ -51,7 +63,7 @@ gulp.task('build', function () {
/**
* developing: rebuild after coding
*/
gulp.task('default', ['build', 'browser-sync', 'watch']);
gulp.task('default', ['build', 'browser-sync', 'watch', 'server']);

/**
* publish: build then bump version
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"gulp-cache": "~0.1.3",
"gulp-clean": "~0.2.4",
"gulp-concat": "~2.2.0",
"gulp-connect": "^2.3.1",
"gulp-jshint": "~1.6.0",
"gulp-load-plugins": "~0.5.1",
"gulp-remove-use-strict": "0.0.2",
Expand Down

0 comments on commit 7b8e784

Please sign in to comment.