0

I'm proxying a website through browsersync and injecting the css/js, that way I can use zurb foundation and sass on a hosted environment, where I don't have access to the HTML files/SSH, since it's all build in an browserbased editor. So I have to proxy it, inject styles and js. And then when it's all done upload it. But for some reason I cannot seem to get sourcemaps to work with my setup. An extra pair of eyes would be welcome.

folder hierarchy:

+ assets (css + js in here)
+ node_modules
+ scss (scss in here)

heres my gulpfile:

const gulp          = require('gulp');
const sass          = require('gulp-sass');
const autoprefixer  = require('gulp-autoprefixer');
const sourcemaps    = require('gulp-sourcemaps');
const browserSync   = require('browser-sync').create();
function style(){
    return gulp.src('./scss/**/*.scss')
    // sourcemaps
        .pipe( sourcemaps.init( { loadMaps: true, largeFile: true } ) )
        .pipe( sass({ 
                includePaths: ['./node_modules/foundation-sites/scss'],
                noCache: true,
                sourceMap: true,
                errLogToConsole: true
            })
        ).on('error', sass.logError )
        .pipe( autoprefixer({ browsers: ['last 2 versions', 'ie >= 8', 'android >= 4.4', 'ios >= 7'] }) )
        .pipe( sourcemaps.write( './' ) )
        .pipe( gulp.dest( './assets' ) )
        .pipe( browserSync.stream() );
}
function watch(){
    browserSync.init({
        plugins: ['bs-console-qrcode'],
        open: false,
        proxy: "https://somedomain.com/",
        files: ['assets/**'],
        serveStatic: ["assets/"],
        rewriteRules: [
            {
                match: new RegExp('somedir/inject.css'),
                fn: function() {
                  return '/addMe.css';
                }
            }
        ],
        snippetOptions: {
            rule: {
                match: /<\/body>/i,
                fn: function (snippet, match) {
                    return '<script src="/js/vendor/what-input.js"></script>' + 
                    '<script src="/js/vendor/foundation.min.js"></script>' + 
                    '<script type="text/javascript" src="/addMe.js" ></script>' + snippet + match;
                }
            }
        }
    });
    gulp.watch( './scss/**/*.scss', style );
    gulp.watch( './assets/**.js' ).on( 'change', browserSync.reload );
}

exports.style = style;
exports.watch = watch;

any ideas?

Some one else
  • 325
  • 1
  • 3
  • 17

0 Answers0