简体   繁体   English

webpack监视不会触发

[英]webpack watch doesn't trigger

I run webpack with native file system (inotify) support, also tested with chokidar and it correctly picked up all changes to files on that filesystem/folder. 我运行带有本机文件系统(inotify)支持的webpack,并且也使用chokidar进行了测试,它可以正确拾取该文件系统/文件夹上文件的所有更改。

The webpack configuration in Sage 9 WordPress base theme is used ( https://github.com/roots/sage/blob/c21df9965ff8217c3b4ff90bbe6099206d7b4fbf/resources/assets/config.json#L16 ). 使用了Sage 9 WordPress基本主题中的Webpack配置( https://github.com/roots/sage/blob/c21df9965ff8217c3b4ff90bbe6099206d7b4fbf/resources/assets/config.json#L16 )。 Only the PHP files are listed for being watched on - but their dependencies (SCSS/JS/...) are also watched? 仅列出了要监视的PHP文件-但还监视了它们的依赖项(SCSS / JS / ...)?

I start webpack watch with npm/yarn package script that starts webpack with $ webpack --hide-modules --watch --config resources/assets/build/webpack.config.js 我用npm / yarn包脚本启动webpack监视,该脚本以$ webpack --hide-modules --watch --config resources/assets/build/webpack.config.js

Webpack is watching the files… [BS] [HTML Injector] Running... [BS] Proxying: http://dev:8084 [BS] Access URLs: ---------------------------------- Local: http://localhost:3000 External: http://127.0.0.1:3000 ---------------------------------- UI: http://localhost:3001 UI External: http://127.0.0.1:3001 ---------------------------------- [BS] Watching files...

However, changing files - even just the PHP files specified in watch array above - doesn't trigger any update by webpack. 但是,更改文件-甚至只是上述watch数组中指定的PHP文件-都不会触发webpack进行任何更新。 What config could be missing? 可能缺少什么配置? Are there any ways finding out what exactly is webpack watching - and whether it really detects a change (and just ignores it) or not? 有什么方法可以找出webpack到底在监视什么,以及它是否真的检测到更改(只是忽略了更改)?

The reason was CORS, the script that should load new webpack builds is blocked by browser due to CORS restrictions. 原因是CORS,由于CORS限制,应加载新的Webpack版本的脚本被浏览器阻止。 It is possible to configure browserSync to send proper headers for CORS, also see https://discourse.roots.io/t/sage-9-browsersync-not-loading-any-css-at-all-on-yarn-run-start/11332/26 . 可以将browserSync配置为发送正确的CORS标头,另请参阅https://discourse.roots.io/t/sage-9-browsersync-not-loading-any-css-at-all-on-yarn-run -start / 11332/26

new BrowserSyncPlugin({ target, open: config.open, proxyUrl: config.proxyUrl, watch: config.watch, delay: 500, advanced: { browserSync: { cors: true, }, }, }),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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