zorigitano/multipage-webpack-plugin

[WIP] Design - Optional - Service Worker

Opened this issue · 1 comments

[WIP] Scenario (Optional) ( #4 )

Fixture

webpack.config.js

const MultipageWebpackPlugin = require(multipage-webpack-plugin);

const config = {
  entry: {
    a: './src/a.js',
    b: './src/b.js'
  },
  output: {
    filename: '[name].chunk.js',
    path: path.join(__dirname, "dist")
  },
  module: {
    /* ... */
  },
  plugins: [
    new MultipageWebpackPlugin()
  ]
};

module.exports = config;

Service Workers

How would service workers be implemented in a "default, out of the box way" for multi page applications (that do not use client routers, or server rendering)?

What existing work can we leverage to help accomplish this behavior (offline-plugin / sw-precache-plugin (cc @NekR @addyosmani))

What are some possible defaults for server rendered applications in these regards that make sense?

Example derived from fixture above:

├── dist/
│   ├── a/ 
│   ├─── index.html
│   ├── b/ 
│   ├─── index.html
│   ├── a.js 
│   ├── b.js
│   ├── shared.js 
│   ├── inline.js
│   ├── vendors.js
│   ├── a.css (if applicable)

** a/index.html **

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Webpack App</title>
  </head>
  <body>
    <script type="text/javascript" src="../../inline.chunk.js"></script>
    <script type="text/javascript" src="../../shared.bundle.js"></script>
    <script type="text/javascript" src="../../vendor.chunk.js"></script>
    <script type="text/javascript" src="../../a.chunk.js"></script>
  </body>
</html>

@NekR I have created the issue "layout" for you to discuss the potential design. The questions in bold, that can be discussed or answered etc.