B
B
Breeze12017-08-30 17:53:41
gulp.js
Breeze1, 2017-08-30 17:53:41

Gulps.js html files?

Please tell me, when you run gulp watch, index.html automatically opens in the browser, if I have more than one html file, how can I change the loading of the html I need?
gulp.task('watch', ['sass', 'scripts', 'browser-sync'], function() {
gulp.watch('app/sass/**/*.sass', ['sass'] );
gulp.watch(['libs/**/*.js', 'app/js/common.js'], ['scripts']);
gulp.watch('app/*.html', browserSync. reload);
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eustatos, 2017-08-30
@Breeze1

The first option, in the browser-sync settings in gulpfile.js, specify the page that should open when executing gulp watch

var gulp        = require('gulp');
var browserSync = require('browser-sync').create();

// Static server
gulp.task('browser-sync', function() {
    browserSync.init({
        server: {
            baseDir: "./",
            index: "other.html"
        }
    });
});

Option two, specify the desired page in the address bar. And if it is within baseDir, then when changing files, the browser will reload it automatically.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question