zorigitano / multipage-webpack-plugin

A plugin that makes handling templates and asset distribution for multi-page applications using webpack trivial
Apache License 2.0
170 stars 15 forks source link

[WIP] Design - Optional - Service Worker #8

Open TheLarkInn opened 7 years ago

TheLarkInn commented 7 years ago

[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>
TheLarkInn commented 7 years ago

@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.