Я установил workbox-cli
и, используя приведенную ниже конфигурацию, расположен в config.js
const {InjectManifest} = require('workbox-webpack-plugin');
const path = require('path');
module.exports = {
webpack: function(config, env) {
config.plugins.push(
new InjectManifest({
globPatterns: ['**/*.{js,css}'],
swSrc: path.join('public', 'custom-service-worker.js'),
swDest: 'service-worker.js',
maximumFileSizeToCacheInBytes: 5000000,
})
);
return config;
}
}
и затем запущен
workbox generateSW config.js
Я получаю
Ваша конфигурация неверна:
{"webpack": function (config, env) {\ n config.plugins.pu sh (\ n новый InjectManifest ({\ n> globPatterns: ['** / *. {js, css}'], \ n swSr c: path.join ('publi c', 'custom-service-> worker. js '), \ n swDest:' service-worker. js ', \ n MaximumFileSizeToCacheInBytes:> 5000000, \ n}) \ n); \ n return config; \ n}, "swDest" [ 1]: - отсутствует -}
[1] требуется "swDest"
Я не уверен, что еще делать, потому что я предоставляю swDest