/// The browser sync prototyping gulp.task('bsync', () => { // Syncs browser browserSync.init({ server: { baseDir: './' }, open: true, startPath: "./test/html/test-all.html", // Makes it easier to test on external mobile devices host: "0.0.0.0", tunnel: true }); // Detect change -> rebuild TS gulp.watch(['src/**.js'], gulp.series('minify')); });
gulp.task('styles', () => { return gulp .src(routes.styles.scss) .pipe(plumber({})) .pipe(sass()) .pipe(gulp.dest(routes.files.css)) .pipe(browserSync.stream()); });
gulp.task('serve', ['styles', 'templates'], () => { browserSync.init({ server: `${baseDirs.dist}`, }); gulp.watch( [routes.templates.pug, routes.templates._pug, routes.scripts.js], ['templates'] ); gulp.watch([routes.styles.scss, routes.styles._scss], ['styles']); });
gulp.task('templates', ['styles'], () => { return gulp .src([routes.templates.pug, '!' + routes.templates._pug]) .pipe(pugLint()) .pipe(plumber({})) .pipe( pug({ locals: { emojis: lifes() }, }) ) .pipe(gulp.dest(routes.files.html)) .pipe(browserSync.stream()); });
function bundle() { gutil.log('Compiling JS...'); return bundler.bundle() .on('error', function (err) { gutil.log(err.message); browserSync.notify("Browserify Error!"); this.emit("end"); }) .pipe(source(config.js.dist.filename)) .pipe(gulp.dest(config.js.dist.path)) .pipe(reload({stream: true, once: true})); }
gulp.task('watch', ['serve'], function() { gulp.watch(paths.source, ['build-system', browserSync.reload]).on('change', reportChange); gulp.watch(paths.html, ['build-html', browserSync.reload]).on('change', reportChange); gulp.watch(paths.style, ['build-styles']).on('change', reportChange); gulp.watch(paths.style, function() { return gulp.src(paths.style) .pipe(browserSync.stream()); }).on('change', reportChange); });
gulp.task('browser-sync', function() { browserSync.init(null, { baseDir: config.bSync.baseDir, proxy: config.bSync.proxy, port: config.bSync.port }); });
gulp.task('source', function(){ gulp.src('src/example/**/*.!(less)', option) .pipe(gulp.dest(dist)) .pipe(browserSync.reload({stream: true})); });
gulp.task('react', function () { return gulp.src('app/jsx/*.jsx') .pipe(react()) .pipe(gulp.dest('app/js')) .pipe(browserSync.reload({ // Compile jsx into js & auto-inject into browsers stream: true })); });
gulp.task('images', function() { return gulp.src(config.src) .pipe(changed(config.dest)) // Ignore unchanged files .pipe(imagemin()) // Optimize .pipe(gulp.dest(config.dest)) .pipe(browserSync.reload({stream:true})); });
gulp.task('browser-sync', ['build', 'nodemon'], function() { browserSync.init({ proxy: 'http://localhost:9000', port: 7000, browser: ['google chrome'] }); });
gulp.task('serve', ['styles', 'templates'], () => { browserSync.init({ server: `${baseDirs.dist}`, }); gulp.watch( [routes.templates.pug, routes.templates._pug, routes.scripts.js], ['templates'] ); gulp.watch([routes.styles.scss, routes.styles._scss], ['styles']); });
gulp.task('styles', () => { return gulp .src(routes.styles.scss) .pipe(plumber({})) .pipe(sass()) .pipe(gulp.dest(routes.files.css)) .pipe(browserSync.stream()); });
gulp.task('templates', ['styles'], () => { return gulp .src([routes.templates.pug, '!' + routes.templates._pug]) .pipe(pugLint()) .pipe(plumber({})) .pipe( pug({ locals: { emojis: lifes() }, }) ) .pipe(gulp.dest(routes.files.html)) .pipe(browserSync.stream()); });
gulp.task('browser-sync', ['nodemon'], function() { browserSync.init(null, { proxy: "http://localhost:3000", // port of node server }); });