I apologize if the question already was to find, and that it has an answer, but in research on intenert, I did not find anything which worked.
Here is my problem, I started with workbox, and I tried to integrate it into my Symfony 4 application which still uses webpack, but it does not work properly. So I tried to generate the service worker with the cli, but I still can't get it to work.
My webpack encore configuration:
const Encore = require('@symfony/webpack-encore');
const CompressionPlugin = require('compression-webpack-plugin');
const {GenerateSW, InjectManifest} = require('workbox-webpack-plugin');
const path = require('path')
Encore
.setOutputPath('public/build/')
.setPublicPath('/build')
.addEntry('app', './assets/js/app.js')
.addEntry('cart', './assets/js/cart.js')
.addEntry('site', './assets/js/site.js')
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
.enableVersioning(Encore.isProduction())
.enableSassLoader()
.enableVueLoader(() => {}, { runtimeCompilerBuild: false })
.addLoader({
test: /\.exec\.js$/,
loader: 'script-loader'
})
.autoProvidejQuery()
.autoProvideVariables({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
})
.enableSingleRuntimeChunk()
.addPlugin(new CompressionPlugin())
.addPlugin(new GenerateSW({swDest: 'sw.js'}))
.addPlugin(new InjectManifest({
swSrc: 'sw.js',
exclude: [
/\.map$/,
/manifest$/,
/\.htaccess$/,
/service-worker\.js$/,
/sw\.js$/,
],
}));
module.exports = Encore.getWebpackConfig();
for webpack generate error i have found this: https://github.com/GoogleChrome/workbox/issues/1513 but
After cli generateSW i have this error:
error
Can't find self.__WB_MANIFEST in your SW source.
for wb manifest i have found this: Webpack workbox Can't find self.__WB_MANIFEST in your SW source but doesn't work for me
I think the problem comes from the url generated by webpack and i have found this: Can't install service worker of workbox-webpack-plugin in root url for React app, it's installing at localhost:8080/dist But I don't see how it helps me in my configuration.
I have tried with path.resolve (because on forum i have seen work), but don't work for me, i get this error:
Can't find self.__WB_MANIFEST in your SW source.
Thank for your help !