Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running but not streaming/injecting #683

Closed
filipemerker opened this issue Jun 17, 2015 · 4 comments
Closed

Running but not streaming/injecting #683

filipemerker opened this issue Jun 17, 2015 · 4 comments

Comments

@filipemerker
Copy link

I'm experiencing a big trouble here. I Already had look up every issue around and everyonde gets it working but not me. That's my code

'use strict';

var gulp        = require('gulp'),
    uglify      = require('gulp-uglify'),
    minify      = require('gulp-minify-css'),
    concat      = require('gulp-concat'),
    sass        = require('gulp-sass'),
    browserSync = require('browser-sync').create(),
    plumber     = require('gulp-plumber'),
    spritesmith = require('gulp.spritesmith'),
    neat        = require('node-neat').includePaths;

//////////////////////////////
// PATHS
//////////////////////////////
var path = {
  sassWatch: [
    'assets/scss/*.scss',
    'assets/scss/**/*.scss'
  ],
  sass_src: 'assets/scss/*.scss',
  sass_dest: 'dist/css',
  js_lint_src: [
      'dist/js/*.js'
  ],
  js_src : [
      'assets/js/*.js'
  ],
  js_dest : 'dist/js/'
};

//////////////////////////////
// BrowserSync
//////////////////////////////
gulp.task('browser-sync', function() {
  //watch files
    browserSync.init(null, {
        files: ['dist/**/*.*'],
        proxy: "http://mmda-treinamento.l"
    });
});

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

//////////////////////////////
// JS Tasks
//////////////////////////////
gulp.task('js', function () {
    gulp.src(path.js_src)
        .pipe(uglify())
        .pipe(concat('main.js'))
        .pipe(gulp.dest('dist/js'));
});

//////////////////////////////
// SASS Tasks
//////////////////////////////
gulp.task('sass', function(){
    gulp.src(path.sass_src)
        .pipe(sass({
            includePaths: ['styles'].concat(neat)
        }))
        .pipe(minify())
        .pipe(concat('style.css'))
        .pipe(gulp.dest('dist/css'))
        .pipe(browserSync.reload({stream: true}))
});

//////////////////////////////
// SPRITE Tasks
//////////////////////////////
gulp.task('sprite', function () {
  var spriteData = gulp.src('dist/img/sprite/*.png')
  .pipe(spritesmith({
    imgName: 'sprite.png',
    cssName: 'sprite.scss',
    optimizationLevel: 7
  }));
  spriteData.img.pipe(gulp.dest('dist/img/'));
  spriteData.css.pipe(gulp.dest('assets/scss/config/'));
});

//////////////////////////////
// Watch Tasks
//////////////////////////////
gulp.task('watch', ['browser-sync'], function () {
    gulp.watch(path.js_src, ['js']);
    gulp.watch(path.sassWatch, ['sass']);
    gulp.watch('gulpfile.js', ['default']);
    gulp.watch('assets/img/sprite/*.*', ['sprite']);
});

//////////////////////////////
//Default Tasks
//////////////////////////////
gulp.task('default', [
    'sass',
    'js',
    'watch',
    'sprite'
]);

And terminal returns me that

[13:51:40] Using gulpfile /www/mmda-treinamento/sites/all/themes/teste/gulpfile.js
[13:51:40] Starting 'sass'...
[13:51:40] Finished 'sass' after 9.31 ms
[13:51:40] Starting 'js'...
[13:51:40] Finished 'js' after 3.61 ms
[13:51:40] Starting 'browser-sync'...
[13:51:40] Finished 'browser-sync' after 9.46 ms
[13:51:40] Starting 'watch'...
[13:51:40] Finished 'watch' after 15 ms
[13:51:40] Starting 'sprite'...
[13:51:40] Finished 'sprite' after 2.15 ms
[13:51:40] Starting 'default'...
[13:51:40] Finished 'default' after 6.13 μs
[BS] 1 file changed (style.css)
[BS] 1 file changed (style.css)
[BS] Proxying: http://mmda-treinamento.l
[BS] Access URLs:
 ----------------------------------
       Local: http://localhost:4006
    External: http://10.0.0.29:4006
 ----------------------------------
          UI: http://localhost:3058
 UI External: http://10.0.0.29:3058
 ----------------------------------
[BS] Watching files...

And every scss file that i edit, it returns

[13:51:58] Starting 'sass'...
[13:51:58] Finished 'sass' after 3.63 ms
[BS] 1 file changed (style.css)
[BS] File changed: dist/css/style.css

But it neve got any close of injecting something in the page.
The BrowserSync itself works, if i force the reload, it work, but never injection.

Tnx

@shakyShane
Copy link
Contributor

  1. Do you see 'Connected to Browsersync' message every time you reload the browser (top right)?
  2. Does your page contain a link element with style.css as the href?

@filipemerker
Copy link
Author

  1. Yes.
  2. No, it has a <style>@import </style> (Cuz i'm using drupal, and i have no way to change that without a external module, that i'm not allowed to add)
<style type="text/css" media="all">
@import url("http://mmda-treinamento.l/sites/all/themes/teste/dist/css/style.css?nq22qp");
</style>

@shakyShane
Copy link
Contributor

Ah ok, please see #10

tl;dr - we do not currently support this, but we will do soon.

@ArtemVPankov
Copy link

ArtemVPankov commented Nov 10, 2020

Hi! insert this <script async="" src="/browser-sync/browser-sync-client.js"></script> before </ body > if u use proxy on browserSync function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants