forked from Mirrors/elk
fix: patch pwa plugin
This commit is contained in:
parent
835269fa1d
commit
af9785c8e8
3 changed files with 183 additions and 3 deletions
|
@ -132,7 +132,8 @@
|
||||||
"vue": "3.2.45"
|
"vue": "3.2.45"
|
||||||
},
|
},
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
"nuxt-security@0.13.0": "patches/nuxt-security@0.13.0.patch"
|
"nuxt-security@0.13.0": "patches/nuxt-security@0.13.0.patch",
|
||||||
|
"vite-plugin-pwa@0.14.7": "patches/vite-plugin-pwa@0.14.7.patch"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"simple-git-hooks": {
|
"simple-git-hooks": {
|
||||||
|
|
175
patches/vite-plugin-pwa@0.14.7.patch
Normal file
175
patches/vite-plugin-pwa@0.14.7.patch
Normal file
|
@ -0,0 +1,175 @@
|
||||||
|
diff --git a/dist/index.js b/dist/index.js
|
||||||
|
index 3fc6a2dd5f9ebaf20504db26a32e809cac929480..693f015856bdbfdfcf67b066877b9f349061d5cd 100644
|
||||||
|
--- a/dist/index.js
|
||||||
|
+++ b/dist/index.js
|
||||||
|
@@ -285,15 +285,6 @@ async function loadWorkboxBuild() {
|
||||||
|
return require("workbox-build");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
-async function loadRollupReplacePlugin() {
|
||||||
|
- try {
|
||||||
|
- const { createRequire } = await import("module").then((m) => m.default || m);
|
||||||
|
- const nodeRequire = createRequire(_dirname);
|
||||||
|
- return nodeRequire("@rollup/plugin-replace");
|
||||||
|
- } catch (_) {
|
||||||
|
- return require("@rollup/plugin-replace");
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
async function generateRegisterSW2(options2, mode, source = "register") {
|
||||||
|
const sw = options2.buildBase + options2.filename;
|
||||||
|
const scope = options2.scope;
|
||||||
|
@@ -335,38 +326,29 @@ async function generateInjectManifest(options2, viteOptions) {
|
||||||
|
await generateServiceWorker(options2, viteOptions);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
- const vitePlugins = options2.vitePlugins;
|
||||||
|
- const includedPluginNames = [];
|
||||||
|
- if (typeof vitePlugins === "function")
|
||||||
|
- includedPluginNames.push(...vitePlugins(viteOptions.plugins.map((p) => p.name)));
|
||||||
|
- else
|
||||||
|
- includedPluginNames.push(...vitePlugins);
|
||||||
|
- if (includedPluginNames.length === 0)
|
||||||
|
- includedPluginNames.push(...defaultInjectManifestVitePlugins);
|
||||||
|
- const replace = await loadRollupReplacePlugin();
|
||||||
|
- const plugins = [
|
||||||
|
- replace({
|
||||||
|
- "preventAssignment": true,
|
||||||
|
- "process.env.NODE_ENV": JSON.stringify(options2.mode)
|
||||||
|
- }),
|
||||||
|
- ...viteOptions.plugins.filter((p) => includedPluginNames.includes(p.name))
|
||||||
|
- ];
|
||||||
|
- const { rollup } = await import("rollup");
|
||||||
|
- const bundle = await rollup({
|
||||||
|
- input: options2.swSrc,
|
||||||
|
- plugins
|
||||||
|
+ const { build } = await import("vite");
|
||||||
|
+ const define = { ...viteOptions.define ?? {} };
|
||||||
|
+ define["process.env.NODE_ENV"] = JSON.stringify(options2.mode);
|
||||||
|
+ await build({
|
||||||
|
+ base: viteOptions.base,
|
||||||
|
+ build: {
|
||||||
|
+ sourcemap: viteOptions.build.sourcemap,
|
||||||
|
+ lib: {
|
||||||
|
+ entry: options2.swSrc,
|
||||||
|
+ name: "app",
|
||||||
|
+ formats: [options2.rollupFormat]
|
||||||
|
+ },
|
||||||
|
+ rollupOptions: {
|
||||||
|
+ output: {
|
||||||
|
+ entryFileNames: options2.filename
|
||||||
|
+ }
|
||||||
|
+ },
|
||||||
|
+ outDir: options2.outDir,
|
||||||
|
+ emptyOutDir: false
|
||||||
|
+ },
|
||||||
|
+ configFile: false,
|
||||||
|
+ define
|
||||||
|
});
|
||||||
|
- try {
|
||||||
|
- await bundle.write({
|
||||||
|
- format: options2.rollupFormat,
|
||||||
|
- exports: "none",
|
||||||
|
- inlineDynamicImports: true,
|
||||||
|
- file: options2.injectManifest.swDest,
|
||||||
|
- sourcemap: viteOptions.build.sourcemap
|
||||||
|
- });
|
||||||
|
- } finally {
|
||||||
|
- await bundle.close();
|
||||||
|
- }
|
||||||
|
if (!options2.injectManifest.injectionPoint)
|
||||||
|
return;
|
||||||
|
const injectManifestOptions = {
|
||||||
|
diff --git a/dist/index.mjs b/dist/index.mjs
|
||||||
|
index 4353dc00f19298bf56e3f970a7e27b2266e8d33d..e7407dcddc4fe67a1c08c70c2c5b1700fd89b465 100644
|
||||||
|
--- a/dist/index.mjs
|
||||||
|
+++ b/dist/index.mjs
|
||||||
|
@@ -258,15 +258,6 @@ async function loadWorkboxBuild() {
|
||||||
|
return __require("workbox-build");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
-async function loadRollupReplacePlugin() {
|
||||||
|
- try {
|
||||||
|
- const { createRequire } = await import("module").then((m) => m.default || m);
|
||||||
|
- const nodeRequire = createRequire(_dirname);
|
||||||
|
- return nodeRequire("@rollup/plugin-replace");
|
||||||
|
- } catch (_) {
|
||||||
|
- return __require("@rollup/plugin-replace");
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
async function generateRegisterSW2(options2, mode, source = "register") {
|
||||||
|
const sw = options2.buildBase + options2.filename;
|
||||||
|
const scope = options2.scope;
|
||||||
|
@@ -308,38 +299,29 @@ async function generateInjectManifest(options2, viteOptions) {
|
||||||
|
await generateServiceWorker(options2, viteOptions);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
- const vitePlugins = options2.vitePlugins;
|
||||||
|
- const includedPluginNames = [];
|
||||||
|
- if (typeof vitePlugins === "function")
|
||||||
|
- includedPluginNames.push(...vitePlugins(viteOptions.plugins.map((p) => p.name)));
|
||||||
|
- else
|
||||||
|
- includedPluginNames.push(...vitePlugins);
|
||||||
|
- if (includedPluginNames.length === 0)
|
||||||
|
- includedPluginNames.push(...defaultInjectManifestVitePlugins);
|
||||||
|
- const replace = await loadRollupReplacePlugin();
|
||||||
|
- const plugins = [
|
||||||
|
- replace({
|
||||||
|
- "preventAssignment": true,
|
||||||
|
- "process.env.NODE_ENV": JSON.stringify(options2.mode)
|
||||||
|
- }),
|
||||||
|
- ...viteOptions.plugins.filter((p) => includedPluginNames.includes(p.name))
|
||||||
|
- ];
|
||||||
|
- const { rollup } = await import("rollup");
|
||||||
|
- const bundle = await rollup({
|
||||||
|
- input: options2.swSrc,
|
||||||
|
- plugins
|
||||||
|
+ const { build } = await import("vite");
|
||||||
|
+ const define = { ...viteOptions.define ?? {} };
|
||||||
|
+ define["process.env.NODE_ENV"] = JSON.stringify(options2.mode);
|
||||||
|
+ await build({
|
||||||
|
+ base: viteOptions.base,
|
||||||
|
+ build: {
|
||||||
|
+ sourcemap: viteOptions.build.sourcemap,
|
||||||
|
+ lib: {
|
||||||
|
+ entry: options2.swSrc,
|
||||||
|
+ name: "app",
|
||||||
|
+ formats: [options2.rollupFormat]
|
||||||
|
+ },
|
||||||
|
+ rollupOptions: {
|
||||||
|
+ output: {
|
||||||
|
+ entryFileNames: options2.filename
|
||||||
|
+ }
|
||||||
|
+ },
|
||||||
|
+ outDir: options2.outDir,
|
||||||
|
+ emptyOutDir: false
|
||||||
|
+ },
|
||||||
|
+ configFile: false,
|
||||||
|
+ define
|
||||||
|
});
|
||||||
|
- try {
|
||||||
|
- await bundle.write({
|
||||||
|
- format: options2.rollupFormat,
|
||||||
|
- exports: "none",
|
||||||
|
- inlineDynamicImports: true,
|
||||||
|
- file: options2.injectManifest.swDest,
|
||||||
|
- sourcemap: viteOptions.build.sourcemap
|
||||||
|
- });
|
||||||
|
- } finally {
|
||||||
|
- await bundle.close();
|
||||||
|
- }
|
||||||
|
if (!options2.injectManifest.injectionPoint)
|
||||||
|
return;
|
||||||
|
const injectManifestOptions = {
|
||||||
|
diff --git a/package.json b/package.json
|
||||||
|
index 138d97e8a26743d6dfcfa94c29e6b6c20af54e5c..8ef1d02abb43e418ef8ee7bd9d09948587b08865 100644
|
||||||
|
--- a/package.json
|
||||||
|
+++ b/package.json
|
||||||
|
@@ -93,8 +93,6 @@
|
||||||
|
"debug": "^4.3.4",
|
||||||
|
"fast-glob": "^3.2.12",
|
||||||
|
"pretty-bytes": "^6.0.0",
|
||||||
|
- "rollup": "^3.7.2",
|
||||||
|
- "@rollup/plugin-replace": "^5.0.1",
|
||||||
|
"workbox-build": "^6.5.4",
|
||||||
|
"workbox-window": "^6.5.4"
|
||||||
|
},
|
|
@ -7,6 +7,9 @@ patchedDependencies:
|
||||||
nuxt-security@0.13.0:
|
nuxt-security@0.13.0:
|
||||||
hash: 4zi7vnypkav7i5l74w6qfcndqy
|
hash: 4zi7vnypkav7i5l74w6qfcndqy
|
||||||
path: patches/nuxt-security@0.13.0.patch
|
path: patches/nuxt-security@0.13.0.patch
|
||||||
|
vite-plugin-pwa@0.14.7:
|
||||||
|
hash: l4g57j5nsv2ls6qiezwq7acdbm
|
||||||
|
path: patches/vite-plugin-pwa@0.14.7.patch
|
||||||
|
|
||||||
importers:
|
importers:
|
||||||
|
|
||||||
|
@ -212,7 +215,7 @@ importers:
|
||||||
version: 0.15.2(@vueuse/core@10.1.0)(rollup@2.79.1)
|
version: 0.15.2(@vueuse/core@10.1.0)(rollup@2.79.1)
|
||||||
vite-plugin-pwa:
|
vite-plugin-pwa:
|
||||||
specifier: ^0.14.7
|
specifier: ^0.14.7
|
||||||
version: 0.14.7(vite@4.3.1)(workbox-build@6.5.4)(workbox-window@6.5.4)
|
version: 0.14.7(patch_hash=l4g57j5nsv2ls6qiezwq7acdbm)(vite@4.3.1)(workbox-build@6.5.4)(workbox-window@6.5.4)
|
||||||
vue-advanced-cropper:
|
vue-advanced-cropper:
|
||||||
specifier: ^2.8.8
|
specifier: ^2.8.8
|
||||||
version: 2.8.8(vue@3.2.45)
|
version: 2.8.8(vue@3.2.45)
|
||||||
|
@ -13388,7 +13391,7 @@ packages:
|
||||||
- vue
|
- vue
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/vite-plugin-pwa@0.14.7(vite@4.3.1)(workbox-build@6.5.4)(workbox-window@6.5.4):
|
/vite-plugin-pwa@0.14.7(patch_hash=l4g57j5nsv2ls6qiezwq7acdbm)(vite@4.3.1)(workbox-build@6.5.4)(workbox-window@6.5.4):
|
||||||
resolution: {integrity: sha512-dNJaf0fYOWncmjxv9HiSa2xrSjipjff7IkYE5oIUJ2x5HKu3cXgA8LRgzOwTc5MhwyFYRSU0xyN0Phbx3NsQYw==}
|
resolution: {integrity: sha512-dNJaf0fYOWncmjxv9HiSa2xrSjipjff7IkYE5oIUJ2x5HKu3cXgA8LRgzOwTc5MhwyFYRSU0xyN0Phbx3NsQYw==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vite: ^3.1.0 || ^4.0.0
|
vite: ^3.1.0 || ^4.0.0
|
||||||
|
@ -13406,6 +13409,7 @@ packages:
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: false
|
dev: false
|
||||||
|
patched: true
|
||||||
|
|
||||||
/vite-plugin-vue-inspector@3.4.0(vite@4.3.1):
|
/vite-plugin-vue-inspector@3.4.0(vite@4.3.1):
|
||||||
resolution: {integrity: sha512-gAdJ6fCPO7+PcUZJexgdOz27yuzQfEviBSS4c+zLLsItHdUq79oYgoWpPZwIYcE0FDFcAtz8dfG6I1ugWuykrw==}
|
resolution: {integrity: sha512-gAdJ6fCPO7+PcUZJexgdOz27yuzQfEviBSS4c+zLLsItHdUq79oYgoWpPZwIYcE0FDFcAtz8dfG6I1ugWuykrw==}
|
||||||
|
|
Loading…
Reference in a new issue