简体   繁体   中英

browser-sync with webpack not working

I'm writing a webpack configuration. I want to build a browser-sync

Here part of the config

{...}
sync: require('browser-sync-webpack-plugin'),
{...}
const proxyDomain = 'http://demo.test/'
{...}
 const development = [
                new plugins.sync({
                  proxy: proxyDomain,
                  files: [
                    {
                      match: ['**/*.html'],
                      fn: (event, file) => {
                        if (event === "change") {
                          const bs = require('browser-sync').get('bs-webpack-plugin');
                          bs.reload();
                        }
                      }
                    }
                  ]
                })
            ]

But on the way out I get this error

What could I do wrong, and how do I fix this error? Thank you!

I solved the problem. I did not copy much the config.

 "dev": "webpack-dev-server --progress --hide-modules --mode development",


const development = [
                new plugins.sync({
                    host: 'localhost',
                    port: 9090,
                    proxy: 'http://localhost:8080/'
                },
                    {
                        reload: false
                    })
            ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM