Gulp Browsync SourceMap问题

时间:2019-03-15 01:17:14

标签: sass gulp browser-sync

当我将Gulp文件保存在Chrome Dev工具中时,我试图使用Gulp来通过浏览器同步任务更新sass文件,但是却收到错误消息,指示未映射源文件。这里是一个错误,它表明源来自端口3000,该端口是默认端口browsersync使用的。端口8181是我用于xampp的端口。感谢帮助

Sourcemap error

    `   var gulp = require('gulp');
    var sourcemaps = require('gulp-sourcemaps');
    var sass = require('gulp-sass');
    var browserSync = require('browser-sync');
    var reload      = browserSync.reload;
    var connect = require('gulp-connect');
    var autoprefixer = require('gulp-autoprefixer'); // Autoprefixing magic.
    var $    = require('gulp-load-plugins')();


    gulp.task('browser-sync', function() {


        var files = [
          './css/styles.css',
          './**/*.php'
        ];


        browserSync.init(files, {
           proxy: "localhost:8181/appcomm2019/",
          notify: false,
        });


    });


    var sassPaths = [''];


    gulp.task('sass', function () {
     return gulp.src('scss/styles.scss')
      .pipe(sourcemaps.init())
      .pipe(sass().on('error', sass.logError))
          .pipe(autoprefixer({
                browsers: ['last 2 versions'],
                cascade: false
            }))
       .pipe(sourcemaps.write('.', {
                includeContent: false,
                sourceRoot: '../scss'
            }))
      .pipe(gulp.dest('css'))
      .pipe(reload({stream:true}));

    });




    gulp.task('default', ['sass', 'browser-sync'], function () {
        gulp.watch("scss/**/*.scss", ['sass']);
    });



` 

0 个答案:

没有答案