From 5024c384b1a8623fff76ab0bd9eb9a77d69f510f Mon Sep 17 00:00:00 2001 From: dabeng Date: Thu, 5 Jul 2018 14:13:27 +0800 Subject: [PATCH] fix(build): 'grunt serve' results in 404 --- Gruntfile.js | 18 +++++++++++++----- README.md | 5 +++-- package.json | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 447d223020..7e03828ad9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -16,6 +16,9 @@ module.exports = function (grunt) { // '--sass' command line argument exists? var sassBuild = grunt.option('sass'); + // '--skipRebuild' command line argument exists? + var skipRebuild = grunt.option('skipRebuild'); + // load all grunt tasks require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); @@ -836,11 +839,16 @@ module.exports = function (grunt) { ]); }); - grunt.registerTask('serve', [ - 'connect:server', - 'open', - 'watch' - ]); + grunt.registerTask('serve', function () { + if (!skipRebuild){ + grunt.task.run('build'); + } + grunt.task.run([ + 'connect:server', + 'open', + 'watch' + ]); + }); grunt.registerTask('open', function () { open('http://localhost:9000'); diff --git a/README.md b/README.md index a20e4deee6..e8ef7f9295 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ so you get the latest version of the dependencies specified in package.json. ### Live Reload Server -A local development server can be quickly fired up by using the Gruntjs server task: +A local development server can be quickly fired up by using the Gruntjs serve task: ``` npm start @@ -150,7 +150,8 @@ npm start or ``` -grunt server +grunt serve # will build first by default +grunt serve --skipRebuild # flag would allow you to skip the rebuild to save some time ``` This local static asset server (i.e., [http://localhost:9000](http://localhost:9000)) has the advantage of having livereload integration. Thus, if you start the Gruntjs server, any changes you make to `.html` or `.less` files will be automatically reloaded into your browser and the changes reflected almost immediately. This has the obvious benefit of not having to refresh your browser and still be able to see the changes as you add or remove them from your development files. Additionally, any changes made to Jekyll source files (`tests/pages/`) will trigger a Jekyll build. diff --git a/package.json b/package.json index 2347c1672d..60e9fd4fd0 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "patternfly": "grunt build-patternfly", "rcue": "grunt build-rcue", "jekyll": "ruby --version || echo \"Ruby required\"; bundler -v || gem install bundler; bundle check || bundle install; set -e", - "start": "grunt build serve", + "start": "grunt serve", "start-patternfly": "grunt build-patternfly serve", "start-rcue": "grunt build-rcue serve", "grunt": "grunt",