javascript 基本Gulp浏览器同步 - 观看

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 基本Gulp浏览器同步 - 观看相关的知识,希望对你有一定的参考价值。

node_modules
*lock*
# GULP:
## Browser Sync and Watch

*Install:*

- Create file on root folder `package.json` and add this code https://git.io/fAMAZ
- Create file on root folder `gulpfile.js` and add this code https://git.io/fAMAc
- Create file on root folder `.gitignore` and add this code https://git.io/fAMjx
- Run `npm install`
- Run `gulp dev` (or just `gulp`)

----

*FAST install:*

- Run 

`wget -O package.json https://git.io/fAMAZ &&  wget -O gulpfile.js https://git.io/fAMAc && wget -O .gitignore https://git.io/fAMjx && npm install`

- **Run:** `gulp`

{
  "name": "",
  "version": "1.0.0",
  "description": "",
  "main": "",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "",
  "homepage": "",
  "devDependencies": {
  },
  "dependencies": {
    "browser-sync": "^2.24.7",
    "compass-mixins": "^0.12.10",
    "gulp": "^3.9.1"
  }
}
'use strict';

const gulp = require('gulp');

const browserSync = require('browser-sync').create();

gulp.task('serve', function () {
  browserSync.init({
    port: 8890,
    reloadDelay: 500,
    ui: false,
    open: true,
    server: {
      baseDir: './',
      directory: true
    }
  });
});

gulp.task('reload', function (done) {
  browserSync.reload();
  done();
});

gulp.task('watch', ['serve'], function () {
  gulp.watch('./**/*', { interval: 800 }, ['reload']);
});

gulp.task('default', ['watch']);

gulp.task('dev', ['watch']);

以上是关于javascript 基本Gulp浏览器同步 - 观看的主要内容,如果未能解决你的问题,请参考以下文章

使用 Gulp 更改后浏览器同步不刷新页面

浏览器同步、gulp、mongodb 和 express 服务器

gulp实现的多浏览器同步刷新工具

如何使用Gulp Browsersync与Django?

gulp-connect插件浏览器实时同步刷新

javascript Gulp 4 - 具有外部配置的多文件任务。使用gulp-load-plugins的基本gulpfile模板,用于多个任务文件