Browsersync:使用纱线监视功能时浏览器连接的无限循环

时间:2019-01-23 16:21:57

标签: wordpress webpack webpack-dev-server browser-sync

最近获得了由外部机构构建的WordPress项目。我正在尝试设置开发环境。

项目编译正常,我可以在本地服务器上看到它。当我运行yarn watch时,所有内容再次编译并给出预期的消息[Browsersync] Watching files...,然后开始用消息[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98一遍又一遍地重新加载页面。

我的监视命令是否重要"watch": "npm run development -- --watch && webpack-dev-server --progress --colors"

我已经尝试过寻找browsersync.reload()之类的东西,但是没有,所以我不确定是什么原因导致重新加载

在webpack.config.js文件中,我看到了这一点

/**
 * Adds BrowserSync plugin when
 * settings are configured.
 */
if (config.settings.browserSync) {
    console.log("using browsersync settings: " + config.settings.browserSync)
    module.exports.plugins.push(
        new BrowserSyncPlugin(config.settings.browserSync, {
            // Prevent BrowserSync from reloading the page
            // and let Webpack Dev Server take care of this.
            reload: false
        })
    )
}

我添加了console.log,并在终端中看到它在编译过程中正在打印。接下来是它指向的对象

/**
     * Settings of other build features.
     *
     * @type {Object}
     */
    settings: {
        sourceMaps: true,
        styleLint: {},
        browserSync: {
            host: 'localhost',
            port: 3000,
            proxy: 'http://casewareidea.local/',
            open: false,
            reloadDelay: 500,
            files: [
                "*.php",
                "app/**/*.php",
                "resources/templates/**/*.php",
                "resources/assets/js/**/*.js",
                "resources/assets/sass/**/*.{sass,scss}",
                "resources/assets/images/**/*.{jpg,jpeg,png,gif,svg}",
                "resources/assets/fonts/**/*.{eot,ttf,woff,woff2,svg}"
            ]
        }
    }

这是做yarn watch的结果

λ yarn watch
yarn run v1.6.0
$ npm run development -- --watch && webpack-dev-server --progress --colors

> @ development C:\Users\andrew\Documents\projects\IDEA\idea.caseware.com\wp-content\themes\caseware-idea
> cross-env NODE_ENV=development webpack --progress --hide-modules --config build/webpack.config.js "--watch"

using browsersync settings: [object Object]
clean-webpack-plugin: C:\Users\andrew\Documents\projects\IDEA\idea.caseware.com\wp-content\themes\caseware-idea\public has been removed.

Webpack is watching the files…

 95% emitting[BS] [debug] -> Starting Step: Finding an empty port
Hash: 85bf0f52eac82a7afb2d
Version: webpack 2.7.0
Time: 4630ms
                                          Asset       Size  Chunks                    Chunk Names
                      images/see-more-close.png  388 bytes          [emitted]
                                      js/app.js    22.1 kB       0  [emitted]         app
                                  js/app.js.map    33.2 kB       0  [emitted]         app
                                css/app.css.map     113 kB       0  [emitted]         app
                                images/play.svg    1.17 kB          [emitted]
          images/header-principal-help-icon.png  532 bytes          [emitted]
                           images/menu-bars.svg  924 bytes          [emitted]
                            images/sample-1.png    2.21 kB          [emitted]
                          images/menu-close.svg    1.14 kB          [emitted]
                                images/play.png    8.88 kB          [emitted]
                              images/search.svg     1.2 kB          [emitted]
                              images/icon-1.png    1.54 kB          [emitted]
                             images/icon-11.png    1.75 kB          [emitted]
                             images/icon-10.png    2.34 kB          [emitted]
                             images/icon-13.png     1.7 kB          [emitted]
                             images/icon-12.png    3.92 kB          [emitted]
                              images/icon-2.png    2.12 kB          [emitted]
                              images/icon-3.png       2 kB          [emitted]
                              images/icon-4.png    2.44 kB          [emitted]
                              images/icon-5.png    1.03 kB          [emitted]
                              images/icon-7.png    2.04 kB          [emitted]
                              images/icon-6.png    2.96 kB          [emitted]
                              images/icon-8.png    3.51 kB          [emitted]
                              images/icon-9.png    1.66 kB          [emitted]
                                    css/app.css    95.8 kB       0  [emitted]         app
                            images/see-more.png  196 bytes          [emitted]
                            images/facebook.svg    1.05 kB          [emitted]
                         images/google_plus.svg    1.49 kB          [emitted]
                             images/twitter.svg    1.39 kB          [emitted]
                    images/slide-left-arrow.png  177 bytes          [emitted]
                            images/linkedin.svg    1.59 kB          [emitted]
                   images/slide-right-arrow.png  171 bytes          [emitted]
                         images/google-plus.svg    1.49 kB          [emitted]
              images/inline-google-plus.svg.php    1.37 kB          [emitted]
                  images/inline-twitter.svg.php    1.31 kB          [emitted]
                 images/inline-linkedin.svg.php    1.07 kB          [emitted]
                  images/inline-youtube.svg.php    3.86 kB          [emitted]
                             images/youtube.svg    4.08 kB          [emitted]
   images/IDEA_default_pressrelease_561x362.png     211 kB          [emitted]
        images/IDEA_Default_Careers_561x362.png     378 kB          [emitted]  [big]
       images/IDEA_Default_Careers_1440x260.png     735 kB          [emitted]  [big]
                            images/caseware.png    3.96 kB          [emitted]
 images/IDEA_default_UpcomingEvents_561x362.png     536 kB          [emitted]  [big]
                                images/idea.png    9.04 kB          [emitted]
                      images/idea-condensed.png    2.37 kB          [emitted]
  images/IDEA_default_pressrelease_1400x600.png     800 kB          [emitted]  [big]
                             images/Image-1.png     646 kB          [emitted]  [big]
images/IDEA_default_upcomingevents_1400x260.png     911 kB          [emitted]  [big]
[BS] [debug] Found a free port: 3000
[BS] [debug] Setting Option: port - 3000
[BS] [debug] +  Step Complete: Finding an empty port
[BS] [debug] -> Starting Step: Getting an extra port for Proxy
[BS] [debug] +  Step Complete: Getting an extra port for Proxy
[BS] [debug] -> Starting Step: Checking online status
[BS] [debug] Resolved www.google.com, setting online: true
[BS] [debug] Setting Option: online - true
[BS] [debug] +  Step Complete: Checking online status
[BS] [debug] -> Starting Step: Resolve user plugins from options
[BS] [debug] +  Step Complete: Resolve user plugins from options
[BS] [debug] -> Starting Step: Set Urls and other options that rely on port/online status
[BS] [debug] Setting multiple Options
[BS] [debug] +  Step Complete: Set Urls and other options that rely on port/online status
[BS] [debug] -> Starting Step: Setting Internal Events
[BS] [debug] +  Step Complete: Setting Internal Events
[BS] [debug] -> Starting Step: Setting file watchers
[BS] [debug] +  Step Complete: Setting file watchers
[BS] [debug] -> Starting Step: Merging middlewares from core + plugins
[BS] [debug] Setting Option: middleware - List []
[BS] [debug] +  Step Complete: Merging middlewares from core + plugins
[BS] [debug] -> Starting Step: Starting the Server
[BS] [debug] Proxy running, proxing: http://casewareidea.local
[BS] [debug] Running mode: PROXY
[BS] [debug] +  Step Complete: Starting the Server
[BS] [debug] -> Starting Step: Starting the HTTPS Tunnel
[BS] [debug] +  Step Complete: Starting the HTTPS Tunnel
[BS] [debug] -> Starting Step: Starting the web-socket server
[BS] [debug] Setting Option: clientEvents - List [ "scroll", "scroll:element", "input:text", "input:toggles", "form:submit", "form:reset", "click" ]
[BS] [debug] +  Step Complete: Starting the web-socket server
[BS] [debug] -> Starting Step: Starting the UI
[BS] [debug] Setting Option: session - 1548260056123
[BS] [UI] Starting Step: Setting default plugins
[BS] [UI] Step Complete: Setting default plugins
[BS] [UI] Starting Step: Finding a free port
[BS] [UI] Step Complete: Finding a free port
[BS] [UI] Starting Step: Setting options also relevant to UI from BS
[BS] [UI] Step Complete: Setting options also relevant to UI from BS
[BS] [UI] Starting Step: Setting available URLS for UI
[BS] [debug] Getting option via path: urls
[BS] [UI] Step Complete: Setting available URLS for UI
[BS] [UI] Starting Step: Starting the Control Panel Server
[BS] [UI] Using port 3001
[BS] [UI] Step Complete: Starting the Control Panel Server
[BS] [UI] Starting Step: Add element events
[BS] [UI] Step Complete: Add element events
[BS] [UI] Starting Step: Registering default plugins
[BS] [debug] Getting option via path: urls,external
[BS] [UI] Step Complete: Registering default plugins
[BS] [UI] Starting Step: Add options setting event
[BS] [UI] Step Complete: Add options setting event
[BS] [debug] +  Step Complete: Starting the UI
[BS] [debug] -> Starting Step: Merge UI settings
[BS] [debug] Setting Option: urls - Map { "local": "http://localhost:3000", "external": "http://192.168.204.58:3000", "ui": "http://localhost:3001", "ui-external": "http://192.168.204.58:3001" }
[BS] [debug] +  Step Complete: Merge UI settings
[BS] [debug] -> Starting Step: Init user plugins
[BS] [debug] Setting Option: userPlugins -
[BS] [debug] +  Step Complete: Init user plugins
[Browsersync] Proxying: http://casewareidea.local
[Browsersync] Access URLs:
 ---------------------------------------
       Local: http://localhost:3000
    External: http://192.168.204.58:3000
 ---------------------------------------
          UI: http://localhost:3001
 UI External: http://192.168.204.58:3001
 ---------------------------------------
[Browsersync] Watching files...
[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98
[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98
[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98
[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98
[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98
[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98
[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98
[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98
[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98
[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98
[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98
[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98
[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98
[Browsersync] Browser Connected: Chrome, version: 71.0.3578.98

可能无关,但无论如何我都会将其包括在内,因为它可能相关。 当项目加载时,会将其放入html标记中,不知道这是否也可能导致重新加载问题。

<b>Warning</b>:  Use of undefined constant WPE_CLUSTER_ID - assumed 'WPE_CLUSTER_ID' (this will throw an Error in a future version of PHP) in <b>C:\Users\andrew\Documents\projects\IDEA\idea.caseware.com\wp-content\mu-plugins\wpengine-common\plugin.php</b> on line <b>14</b><br>
<br>
<b>Warning</b>:  Use of undefined constant PWP_NAME - assumed 'PWP_NAME' (this will throw an Error in a future version of PHP) in <b>C:\Users\andrew\Documents\projects\IDEA\idea.caseware.com\wp-content\mu-plugins\wpengine-common\wpe-sec.php</b> on line <b>63</b><br>

0 个答案:

没有答案