sw-precache-webpack-plugin icon indicating copy to clipboard operation
sw-precache-webpack-plugin copied to clipboard

Watching "static" HTML/PHP files with Webpack

Open stephan-v opened this issue 7 years ago • 2 comments

BEFORE YOU SUBMIT please read the following:

  • [ ] I'm submitting a bug report
  • [ ] I'm submitting a feature request
  • [x] I'm submitting a support request

webpack version: 3.11.0

sw-precache-webpack-plugin version: 0.11.5

Please tell us about your environment: Linux - Ubuntu 16.04

Browser: [Phantom XX | Chrome XX | Firefox XX | IE XX | Safari XX | Other XX]

Chrome 65

Current behavior:

I am wondering how to properly deal with this. Currently I am caching some Laravel PHP files like so:

dynamicUrlToDependencies: {
    '/': ['resources/views/home.blade.php']
}

This work but because the files are not part of the Webpack pipeline files like these are not being watched and a new service-worker.js file is never being generated once I edit files like home.blade.php.

It generates a hash without any problem but once I change this file I need to re-run my entire Webpack process to generate a new service-worker.js file which contains an updated hash.

I am not sure how a new service-worker.js file is currently being generated when Webpack notices a change in css or js file but the same would need to happen when html files like these have changed. Even if I could get Webpack to notice changes in these files I am unsure how to even call the plugin to re-generated the file.

Is there a good way to deal with this? Hopefully I have my question clear, otherwise ask me anything.

stephan-v avatar Apr 29 '18 22:04 stephan-v

After review how to create a Webpack plugin I see this plugin uses the hook:

compiler.plugin('after-emit', afterEmit);

The Webpack documentation states this runs:

After emitting assets to output dir

So I guess it will be pretty difficult to watch changes in static files with the way this plugin is currently set up?

stephan-v avatar Apr 29 '18 22:04 stephan-v

the plugin is made more toward production, so watching files during dev is out of the scope.

ctf0 avatar Jun 03 '18 16:06 ctf0