NekR / offline-plugin

Offline plugin (ServiceWorker, AppCache) for webpack (https://webpack.js.org/)
MIT License
4.52k stars 295 forks source link

dynamic publicPath option during runtime install #418

Closed Bobgy closed 4 years ago

Bobgy commented 6 years ago

this is a prototype for dynamic publicPath. I got it working for my use case, but it may not work together with other options.

and for FYI, my usage of OfflinePlugin looks like

new OfflinePlugin({
    ServiceWorker: {
        output: '../sw.js',
        scope: '/',
        events: true,
        entry: path.resolve('./.../.../entry.js'), // my entry file
    },
    autoUpdate: false,
    responseStrategy: 'cache-first',
    version: '',
    caches: 'all',
})

add feature #184

Bobgy commented 6 years ago

changed my implementation, now there's fewer changes needed, I just need to change 'install' event implementation

Bobgy commented 6 years ago

there's still some failure for eslint, which I think is related to my new usage of importing a node_module in templates. I'll try to figure out correct configuration later, but I get more confidence in the new implementation

Bobgy commented 6 years ago

and I should add new browser test for the dynamic publicPath, will get back to it when I get time

Bobgy commented 6 years ago

holy crap, accidentally saw this, https://stackoverflow.com/questions/38835273/when-does-code-in-a-service-worker-outside-of-an-event-handler-run I think my implementation is wrong, going to revise on it

Bobgy commented 6 years ago

this version works for me, but the configuration around publicPath seems really complicated to me, I cannot really add my option to other possible configs

Bobgy commented 6 years ago

need some help on that

GGAlanSmithee commented 6 years ago

@Bobgy

Thanks for your contribution. I do not have the capacity (time and knowhow) to provide any meaningful feedback regarding your implementation, but I can tell you put some time into this PR, so wanted to tell you that your effort is appreciated, thanks!

@NekR could we give some feedback to let @Bobgy know if this is a feature we are even interested in, to let him know if it's worth pursuing further?

Bobgy commented 4 years ago

Looks like maintainer doesn't have capacity to review this.