Webpack launch browser automatically

前端 未结 9 963
遥遥无期
遥遥无期 2021-02-03 17:18

Gulp + live reload serves up my content on localhost and (here\'s what I\'m after) launches the browser automatically at the server url whenever i run the gulp

9条回答
  •  终归单人心
    2021-02-03 17:59

    Ive had success using BrowserSync with webpack.

    In webpack.config.js I include this:

    var options = {
        port: 9001,
        host: 'localhost',
        server: {
            baseDir: './public'
        },
        ui: {
            port: 9002
        },
        startPath: process.argv[3].substr(2),
    }
    
    var browserSync = require('browser-sync');
    browserSync(['public/**/*.*'],options);
    

提交回复
热议问题