Skip to content
This repository has been archived by the owner on Nov 20, 2019. It is now read-only.

Webpack bootstrap code in sw.js file #90

Open
hannadrehman opened this issue Oct 4, 2018 · 0 comments
Open

Webpack bootstrap code in sw.js file #90

hannadrehman opened this issue Oct 4, 2018 · 0 comments

Comments

@hannadrehman
Copy link

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

browser: chrome
browser version: 69.0.3497.100
operating system: mac os high sierra
webpack version: 4.17.2

Repro steps.

i am following the exact same steps mentioned in the readme to get it working.
it works but i can see a lot of webpack boilerplate code in my sw.js

// register.js

import runtime from 'serviceworker-webpack-plugin/lib/runtime';
if ('serviceWorker' in navigator) {
  runtime.register();
}

// plugin config

 new ServiceWorkerWebpackPlugin({
      entry: appPath.srcPath+'/service-worker.js',
      publicPath:'/',
      minimize: false,
    }),

// service worker file

importScripts('/sw-toolbox.js'); // eslint-disable-line

const spChache = {
  static: 'static-v1',
  dynamiv: 'dynamic-v1',
};

self.addEventListener('install', (event) => { // eslint-disable-line
  event.waitUntill(
    caches.open(spChache.static)
      .then(cache => cache.addAll(
        serviceWorkerOption.assets, //eslint-disable-line
      )),
  );
});
self.addEventListener('activate', (event) => { // eslint-disable-line
  console.log('WORKER: activated ');
});
toolbox.router.get('/api/*', toolbox.networkFirst, { // eslint-disable-line
  cache: {
    name: spChache.static,
    maxAgeSeconds: 60 * 60 * 1,
  },
});


Desired or expected functionality

it should only contain my written sw.js files. with serviceWorkerOption injected in it

but i am seeing a lot of webpack bootstrap code in my sw.js

// here is some part of my huge sw.js build by webpack

var serviceWorkerOption = {
  "assets": [
    "/assests/images/page-not-found.png",
    "/js/errorpage.js",
    "/js/home.js",
    "/js/main.js",
    "/js/memepage.js",
    "/js/profile.js",
    "/js/register-sw.js",
    "/js/todo.js",
    "/sw-toolbox.js",
    "/icons/icon-72x72.png",
    "/icons/icon-96x96.png",
    "/icons/icon-128x128.png",
    "/manifest.json",
    "/icons/icon-152x152.png",
    "/icons/icon-144x144.png",
    "/icons/icon-192x192.png",
    "/icons/icon-384x384.png",
    "/icons/icon-512x512.png"
  ]
};
        
        /******/ (function(modules) { // webpackBootstrap
/******/ 	var hotApplyOnUpdate = true;
/******/ 	// eslint-disable-next-line no-unused-vars
/******/ 	var hotCurrentHash = "746fbf40f90961685b01";
/******/ 	var hotRequestTimeout = 10000;
/******/ 	var hotCurrentModuleData = {};
/******/ 	var hotCurrentChildModule;
/******/ 	// eslint-disable-next-line no-unused-vars
/******/ 	var hotCurrentParents = [];
/******/ 	// eslint-disable-next-line no-unused-vars
/******/ 	var hotCurrentParentsTemp = [];
/******/
/******/ 	
this keeps on going for abt 3000+ lines.

Mention any other details that might be useful.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant