nodejsによるページホットアップデートのオープン
2014 ワード
1.ローカルサーバのインストール
2.gulpのインストール
3.browser-syncのインストール(管理者方式でコマンドラインを開く)
ファイルルートディレクトリでhttp-serverを開く
このときのポートアドレスなどがスタンバイになることを覚えておいてください
4.gulpfile.jsファイルの追加
5.gulpを実行する
browser-syncにweinreが統合されています
npm install http-server -g
2.gulpのインストール
npm install gulp -g
npm install gulp --save-dev
3.browser-syncのインストール(管理者方式でコマンドラインを開く)
npm install --save-dev browser-sync
ファイルルートディレクトリでhttp-serverを開く
http-server
PS E:\APP\xampp\htdocs\WebRoot> http-server
Starting up http-server, serving ./
Available on:
http://192.168.191.2:8080
http://127.0.0.1:8080
Hit CTRL-C to stop the server
このときのポートアドレスなどがスタンバイになることを覚えておいてください
4.gulpfile.jsファイルの追加
var gulp = require("gulp");
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
gulp.task('serve', function () {
var files = [
'./**/*.css',
'./**/*.js',
'./**/*.html'
];
browserSync.init({
files: files,
//
proxy: "http://localhost:8080/"
});
gulp.on("change", reload);
})
// , gulp, ,
gulp.task("default", function() {
gulp.start(["serve"]);
})
5.gulpを実行する
PS E:\APP\xampp\htdocs\WebRoot> gulp
[21:39:00] Using gulpfile E:\APP\xampp\htdocs\WebRoot\gulpfile.js
[21:39:00] Starting 'default'...
[21:39:00] Starting 'serve'...
[21:39:00] Finished 'serve' after 25 ms
[21:39:00] Finished 'default' after 27 ms
[Browsersync] Proxying: http://localhost:8080
[Browsersync] Access URLs:
--------------------------------------
Local: http://localhost:3001
External: http://192.168.0.109:3001
--------------------------------------
UI: http://localhost:3002
UI External: http://192.168.0.109:3002
--------------------------------------
[Browsersync] Watching files...
[Browsersync] Reloading Browsers...
[Browsersync] Reloading Browsers...
[Browsersync] Reloading Browsers...
browser-syncにweinreが統合されています
。