diff --git a/src/sw.js b/src/sw.js new file mode 100644 index 0000000..647e3e3 --- /dev/null +++ b/src/sw.js @@ -0,0 +1,7 @@ +importScripts('/uv.bundle.js'); +importScripts('/uv.config.js'); +importScripts('/uv.sw.js'); + +const sw = new UVServiceWorker(); + +self.addEventListener('fetch', (event) => event.respondWith(sw.fetch(event))); diff --git a/webpack.config.js b/webpack.config.js index 05913ba..272a7fa 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,7 +2,6 @@ import webpack from 'webpack'; import { fileURLToPath } from 'url'; import TerserPlugin from 'terser-webpack-plugin'; import CopyPlugin from 'copy-webpack-plugin'; -import { resolve } from 'path'; const isDevelopment = process.env.NODE_ENV !== 'production'; @@ -24,7 +23,7 @@ const config = { minimize: !isDevelopment, minimizer: [ new TerserPlugin({ - exclude: ['uv.config.js'], + exclude: ['sw.js', 'uv.config.js'], }), ], }, @@ -34,6 +33,9 @@ const config = { { from: fileURLToPath(new URL('./src/uv.config.js', import.meta.url)), }, + { + from: fileURLToPath(new URL('./src/sw.js', import.meta.url)), + }, ], }), ],