Livereload不在吞咽

Livereload不在吞咽

本文介绍了Livereload不在吞咽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我使用了gulp-webapp(来自yeoman的generator)并添加了一些其他任务(如gulp-sass& gulp-coffee)。

但现在Livereload isn'开始。我需要看到类似这样的内容:
$ b $ pre $ [gulp]实时重载服务器监听:35729



但输出看起来像

 ➜应用程序git:(master)✗gulp watch 
[gulp]使用gulpfile〜/ dev / lsd / app / gulpfile.js
[gulp]启动'clean'...
[gulp]启动'styles'...
[gulp]启动'scripts'...
[gulp]启动'connect'...
[gulp] 68 ms后完成'connect'
在http:// localhost:9000
[gulp]上启动连接网络服务器181 ms后完成'脚本'
[gulp] gulp-size:总计128.75 kB
[gulp] Finished 'styles'806 ms
[gulp]开始'serve'...
[gulp] 5.73 ms后完成'serve'

我不明白,我的问题是什么。



我的 gulpfile.coffee :

 use strict

gulp = require(gulp )
$ = require(gulp-load-plugins)()

gulp.taskstyles, - >
gulp.src(app / styles / main.scss)。pipe($。sass())。pipe($。autoprefixer(last 1 version))。pipe(gulp.dest(。 tmp / styles))。pipe $ .size()

gulp.taskscripts, - >
gulp.src(app / scripts / ** / *。coffee)。pipe($。coffee())。pipe gulp.dest(.tmp / scripts)

gulp.taskhtml,[
styles
scripts
], - >
jsFilter = $ .filter(** / *。js)
cssFilter = $ .filter(** / *。css)
gulp.src(app / * html的)。管($。useref.assets())。管(jsFilter).pipe($。丑化())。管(jsFilter.restore())。管(CSS滤器).pipe($。CSSO( ))。pipe(cssFilter.restore())。pipe($。useref.restore())。pipe($。useref())。pipe(gulp.dest(dist))。pipe $ .size()

gulp.taskclean, - >
gulp.src([
.tmp
dist
],
阅读:false
).pipe $ .clean()

gulp.taskbuild,[
html
字体
]
gulp.taskdefault,[clean] , - >
gulp.startbuild

gulp.taskconnect, - >
connect = require(connect)
app = connect()。use(require(connect-livereload)(port:35729))。use(connect.static(app)) .use(connect.static(。tmp))。use(connect.directory(app))
require(http)。createServer(app).listen(9000) , - >
console.log在http:// localhost:9000上启动连接Web服务器

gulp.taskserve,[
styles
scripts
连接
, - >
require(opn)http:// localhost:9000

gulp.taskwatch,[
clean
serve
], - >
server = $ .livereload()
gulp.watch([
app / *。html
.tmp / styles / ** / *。css
.tmp / scripts / ** / *。js
)。onchange,(file) - >
server.changed file.path

gulp.watchapp / styles / ** / *。scss,[styles]
gulp.watchapp / scripts /****.coffee,[scripts]


解决方案

我一直在使用。它使得使用LiveReload非常简单。

  gulp = require'gulp'
webserver ='gulp-webserver'
path ='path'

gulp.taskwebserver, - >
gulp.src(path.resolve(./ dist))。pipe webserver(
port:8080
livereload:true


I used gulp-webapp (generator from yeoman) and add some other tasks (like gulp-sass & gulp-coffee).

But now Livereload isn't starting. I need to see something like this

[gulp] Live reload server listening on: 35729

But output looks like

➜  app git:(master) ✗ gulp watch
[gulp] Using gulpfile ~/Dev/lsd/app/gulpfile.js
[gulp] Starting 'clean'...
[gulp] Starting 'styles'...
[gulp] Starting 'scripts'...
[gulp] Starting 'connect'...
[gulp] Finished 'connect' after 68 ms
Started connect web server on http://localhost:9000
[gulp] Finished 'scripts' after 181 ms
[gulp] gulp-size: total 128.75 kB
[gulp] Finished 'styles' after 806 ms
[gulp] Starting 'serve'...
[gulp] Finished 'serve' after 5.73 ms

And I don't understand, what is my problem.

My gulpfile.coffee:

"use strict"

gulp = require("gulp")
$ = require("gulp-load-plugins")()

gulp.task "styles", ->
  gulp.src("app/styles/main.scss").pipe($.sass()).pipe($.autoprefixer("last 1 version")).pipe(gulp.dest(".tmp/styles")).pipe $.size()

gulp.task "scripts", ->
  gulp.src("app/scripts/**/*.coffee").pipe($.coffee()).pipe gulp.dest(".tmp/scripts")

gulp.task "html", [
  "styles"
  "scripts"
], ->
  jsFilter = $.filter("**/*.js")
  cssFilter = $.filter("**/*.css")
  gulp.src("app/*.html").pipe($.useref.assets()).pipe(jsFilter).pipe($.uglify()).pipe(jsFilter.restore()).pipe(cssFilter).pipe($.csso()).pipe(cssFilter.restore()).pipe($.useref.restore()).pipe($.useref()).pipe(gulp.dest("dist")).pipe $.size()

gulp.task "clean", ->
  gulp.src([
    ".tmp"
    "dist"
  ],
    read: false
  ).pipe $.clean()

gulp.task "build", [
  "html"
  "fonts"
]
gulp.task "default", ["clean"], ->
  gulp.start "build"

gulp.task "connect", ->
  connect = require("connect")
  app = connect().use(require("connect-livereload")(port: 35729)).use(connect.static("app")).use(connect.static(".tmp")).use(connect.directory("app"))
  require("http").createServer(app).listen(9000).on "listening", ->
    console.log "Started connect web server on http://localhost:9000"

gulp.task "serve", [
  "styles"
  "scripts"
  "connect"
], ->
  require("opn") "http://localhost:9000"

gulp.task "watch", [
  "clean"
  "serve"
], ->
  server = $.livereload()
  gulp.watch([
    "app/*.html"
    ".tmp/styles/**/*.css"
    ".tmp/scripts/**/*.js"
  ]).on "change", (file) ->
    server.changed file.path

  gulp.watch "app/styles/**/*.scss", ["styles"]
  gulp.watch "app/scripts/**/*.coffee", ["scripts"]
解决方案

I have been using gulp-webserver. It makes using LiveReload very simple.

gulp = require 'gulp'
webserver = 'gulp-webserver'
path = 'path'

gulp.task "webserver", ->
    gulp.src(path.resolve("./dist")).pipe webserver(
        port: "8080"
        livereload: true
    )

这篇关于Livereload不在吞咽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 13:10