Open titantwentyone opened 4 years ago
Same problem here. Did you resolve it ?
@titantwentyone maybe the browser is serving an old version from the cache. Have tried going to Devtools > Network tab and checking 'disable cache'? Changes to .html files might be coming through because the browser doesn't cache HTML as aggressively...
Hi ! I've updated this plugin this morning. Your bug seems to come from the cache. If you check the compiled file, do you see the modification ?
I'm having the same issue. I am trying to run a script each time a file is modified at the beggining of the webpack compilation, which creates a new file. When I edit a file that I'm watching with this plugin and hit save, webpack --watch recompiles and runs the script, which then creates this file, but it's content is relevant to prior version of file, not the newest version.
This plugin successfully triggers a compiler "emit" event whenever the external files change.
However, because those files are not included in the actual webpack bundle, no build info or output from webpack is generated, the actual asset which webpack outputs never changes. Other plugins which may be monitoring the output of webpack (like the nodemon-webpack-plugin
), will never re-run.
I came up with this hack to force a rebuild by "touch"ing the output asset every time the "compile" event is emitted:
const path = require('path');
const touch = require('touch');
class WebpackForceRebuildOnEmitPlugin {
apply(compiler) {
compiler.hooks.emit.tapAsync('WebpackForceRebuildOnEmitPlugin', (compilation, callback) => {
const outputPath = compilation.outputOptions.path;
const firstAssetName = compilation.getAssets()[0].name;
const assetToTouch = path.resolve(outputPath, firstAssetName);
touch(assetToTouch);
callback();
});
}
}
I am having a similar issue as described in #8
Ubuntu 18.04 LTS Webpack 4.41.6
My config is:
When dev server is running, the plugin correctly states:
If changes are made to a .part" file the compilation runs, triggers a browser reload and completes with
「wdm」: Compiled successfully.
but the changes are not reflected.When I edit a "part" file, the changes are not reflected immediately but when I edit another file, say a 'htm' or 'scss', the changes do come through.
This also happens when using
webpack --watch
.