First, Gulp-webserver operating environment (winddows system-win8 X64)
1. Install the node. JS base Environment and download the link address.
2. Using NPM Integrated Gulp tool, command prompt wound paste input npm install-g--save-dev Gulp, Global Installation Gulp tool.
3.gulp tool installation After successful, integrated julp-webserver components, specific download integration method can refer to this description, at the Command Prompt window input: npm install--save-dev gulp-webserver, download the integration components.
4. In the Command Prompt window, enter the path of the project, execute the instructions: NPM link Gulp and NPM link gulp-webserver; Integrate the Gulp Toolkit and Gulp-webserver component packages into the root directory of the current project. The goal is to prevent errors when executing gulp instructions directly.
5. So far, the basic environment has been established.
Second, the configuration
1. First build the Gulpfile.js file in the project root directory
<span style= "White-space:pre" ></span>var Gulp = require (' gulp '); <span style= "White-space:pre" > </span>var webserver = require (' Gulp-webserver '); <span style= "White-space:pre" ></span>gulp.task ( ' Webserver ', function () {<span style= "White-space:pre" ></span>gulp.src (' G: '). Pipe (webserver ({//g): <span style= "White-space:pre" ></span>path: ' 2 ',//2 is the path where the project is located <span style= "White-space:pre" ></span>livereload:true,<span style= "White-space:pre" ></span>directoryListing:true,< Span style= "White-space:pre" ></span>open:true,<span style= "White-space:pre" ></span>fallback : ' index.html ' <span style= "White-space:pre" ></SPAN>}); <span style= "White-space:pre" ></span Gulp.task (' Default ', [' webserver ']);
2. Create a index.html file
3. Open a Command Prompt window, navigate to the path of the current project, execute the gulp instruction, if everything is OK, a gulp simple real-time refresh server is assembled.
4. The browser automatically opens the index page in the current directory, changes the content, and the page refreshes in real time.
Gulp-webserver components