-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
watchContentBase watches for the first level only, ignoring deeper folders #1227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Unfortunately this isn't actually a bug in You'll notice that |
@creage I'm not sure why you deleted your comment, but I'm happy to respond none-the-less.
Unfortunately you built a solution around a bug that was subsequently fixed. If you'd like your use-case to be supported, bearing in mind that it's intentionally unsupported at the moment, the right path is to petition the |
@shellscape after some deeper diving into the code, I understood, that this So, I've ended up with writing my custom webpack plugin, which triggers a |
@creage that's great news. please do share your plugin with the community! |
I don't think this person built their use-case around a bug, the documentation for watchContentBase states: "Tell the server to watch the files served by the devServer.contentBase option. File changes will trigger a full page reload." I would say that means all files within that folder. I think your fix for #1208 broke this feature. Either bug should be fixed or if this was genuinely an intended feature then the documentation needs to be updated. |
@creage would you mind sharing your webpack plugin? Also running into this. @shellscape I believe that @BiggAdd has a valid point here — if only watching root for changes is the intended behavior, I believe the documentation needs to updated to reflect that |
This comment has been minimized.
This comment has been minimized.
@chasegiunta well, the plugin code is really simple. The idea is every time some paths different then root are updated, I touch some file in the root, which triggers WDS to recompile. const path = require('path'),
fs = require('fs');
/**
* Forces App to reload by touching index.html everytime module is recompiled
*/
class AppWatchPlugin {
constructor(dest, file) {
this.dest = dest;
this.file = file || 'index.html';
}
apply(compiler) {
compiler.plugin('done', () => {
const currentDate = new Date(),
fullPathOfFile = path.resolve(this.dest, this.file);
fs.utimes(fullPathOfFile, currentDate, currentDate, err => {
if (err) {
console.log(err);
}
});
});
}
}
module.exports = AppWatchPlugin; |
@creage FYI, not a good solution change |
Better example: before(app, server) {
const chokidar = require("chokidar");
const files = [
// Refreshing php files
"**/*.php"
];
chokidar
.watch(files, {
alwaysStat: true,
atomic: false,
followSymlinks: false,
ignoreInitial: true,
ignorePermissionErrors: true,
ignored,
persistent: true
})
.on("all", () => {
server.sockWrite(server.sockets, "content-changed");
});
} |
Appreciate the time & answers to you both @evilebottnawi & @creage . I was really hopeful I could get one of your solutions to work. @creage unfortunately, I can't seem to get the plugin to be called after saving a deeper folder. @evilebottnawi Also tried your solution but ran into issues with globbing (chokidar doesn't seem to like I feel defeated! Any further suggestions you two have would be welcome 😅 ** UPDATE ** |
@evilebottnawi Thanks! Your solution worked perfectly in my use-case. My webpack-dev-server + Jekyll setup - edit: 🤦♂️ as it turns out, I didn't need the manual watchers for my use case at all. |
Code
Expected Behavior
Setting
watchContentBase
totrue
should watchcontentBase
paths all way deepActual Behavior
According to chockidar documentation, setting
depth
parameter limits the depth of folders being traversed, and the fix of #1208 limits it to 0, leading to changes in the deeper folders being ignored, and not triggering recompilation.For Bugs; How can we reproduce the behavior?
contentBase
folder (folder1/folder2/file1.css)watchContentBase: true
The text was updated successfully, but these errors were encountered: