fix: public assets build

This commit is contained in:
Anthony Fu 2023-01-09 12:12:43 +01:00
parent 571deed157
commit 71b19dbe68
4 changed files with 96 additions and 9 deletions

View file

@ -22,12 +22,10 @@ export default defineNuxtModule({
nuxt.options.runtimeConfig.public.env = env
nuxt.options.runtimeConfig.public.buildInfo = buildInfo
nuxt.hook('nitro:config', (config) => {
config.publicAssets = config.publicAssets || []
if (env === 'dev')
config.publicAssets.unshift({ dir: resolve('../public-dev') })
else if (env === 'canary' || env === 'preview' || !isCI)
config.publicAssets.unshift({ dir: resolve('../public-staging') })
})
nuxt.options.nitro.publicAssets = nuxt.options.nitro.publicAssets || []
if (env === 'dev')
nuxt.options.nitro.publicAssets.unshift({ dir: resolve('../public-dev') })
else if (env === 'canary' || env === 'preview' || !isCI)
nuxt.options.nitro.publicAssets.unshift({ dir: resolve('../public-staging') })
},
})

View file

@ -115,7 +115,8 @@
},
"pnpm": {
"patchedDependencies": {
"mlly@1.0.0": "patches/mlly@1.0.0.patch"
"mlly@1.0.0": "patches/mlly@1.0.0.patch",
"nitropack@1.0.0": "patches/nitropack@1.0.0.patch"
}
},
"simple-git-hooks": {

View file

@ -0,0 +1,13 @@
diff --git a/dist/shared/nitro.c8278d90.mjs b/dist/shared/nitro.c8278d90.mjs
index 9ba312fc248da3731720ee7e3b38ba2a85537657..3cd508f0720adb959d94e40c124382ec0110d92c 100644
--- a/dist/shared/nitro.c8278d90.mjs
+++ b/dist/shared/nitro.c8278d90.mjs
@@ -1298,7 +1298,7 @@ async function copyPublicAssets(nitro) {
}
for (const asset of nitro.options.publicAssets) {
if (await isDirectory(asset.dir)) {
- await fse.copy(asset.dir, join(nitro.options.output.publicDir, asset.baseURL));
+ await fse.copy(asset.dir, join(nitro.options.output.publicDir, asset.baseURL), { override: false });
}
}
if (nitro.options.compressPublicAssets) {

View file

@ -4,6 +4,9 @@ patchedDependencies:
mlly@1.0.0:
hash: afe7v34zn4lohdq7767l3tlrje
path: patches/mlly@1.0.0.patch
nitropack@1.0.0:
hash: 5rbw6wsrpkguwhgdzu2jwggidq
path: patches/nitropack@1.0.0.patch
importers:
@ -8578,6 +8581,78 @@ packages:
- utf-8-validate
dev: true
/nitropack/1.0.0_5rbw6wsrpkguwhgdzu2jwggidq:
resolution: {integrity: sha512-788lHgNgC+NKqecwFgMkAQTuTXwuh2hEgOk2sLwV3qPVUogxrl6P3m5eKdt6Mtzx+mlXIw0G/P90B5TNWEqDSQ==}
engines: {node: ^14.16.0 || ^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0}
hasBin: true
dependencies:
'@cloudflare/kv-asset-handler': 0.2.0
'@netlify/functions': 1.3.0
'@rollup/plugin-alias': 4.0.2_rollup@2.79.1
'@rollup/plugin-commonjs': 23.0.3_rollup@2.79.1
'@rollup/plugin-inject': 5.0.2_rollup@2.79.1
'@rollup/plugin-json': 5.0.2_rollup@2.79.1
'@rollup/plugin-node-resolve': 15.0.1_rollup@2.79.1
'@rollup/plugin-replace': 5.0.1_rollup@2.79.1
'@rollup/plugin-wasm': 6.0.1_rollup@2.79.1
'@rollup/pluginutils': 5.0.2_rollup@2.79.1
'@vercel/nft': 0.22.1
archiver: 5.3.1
c12: 1.0.1
chalk: 5.1.2
chokidar: 3.5.3
consola: 2.15.3
cookie-es: 0.5.0
defu: 6.1.1
destr: 1.2.2
dot-prop: 7.2.0
esbuild: 0.15.18
escape-string-regexp: 5.0.0
etag: 1.8.1
fs-extra: 10.1.0
globby: 13.1.2
gzip-size: 7.0.0
h3: 1.0.1
hookable: 5.4.2
http-proxy: 1.18.1
is-primitive: 3.0.1
jiti: 1.16.1
klona: 2.0.5
knitwork: 1.0.0
listhen: 1.0.1
mime: 3.0.0
mlly: 1.0.0_afe7v34zn4lohdq7767l3tlrje
mri: 1.2.0
node-fetch-native: 1.0.1
ofetch: 1.0.0
ohash: 1.0.0
pathe: 1.0.0
perfect-debounce: 0.1.3
pkg-types: 1.0.1
pretty-bytes: 6.0.0
radix3: 1.0.0
rollup: 2.79.1
rollup-plugin-terser: 7.0.2_rollup@2.79.1
rollup-plugin-visualizer: 5.8.3_rollup@2.79.1
scule: 1.0.0
semver: 7.3.8
serve-placeholder: 2.0.1
serve-static: 1.15.0
source-map-support: 0.5.21
std-env: 3.3.1
ufo: 1.0.1
unenv: 1.0.0
unimport: 1.1.0_rollup@2.79.1
unstorage: 1.0.1
transitivePeerDependencies:
- bufferutil
- debug
- encoding
- supports-color
- utf-8-validate
dev: true
patched: true
/no-case/3.0.4:
resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==}
dependencies:
@ -8836,7 +8911,7 @@ packages:
knitwork: 1.0.0
magic-string: 0.26.7
mlly: 1.0.0_afe7v34zn4lohdq7767l3tlrje
nitropack: 1.0.0
nitropack: 1.0.0_5rbw6wsrpkguwhgdzu2jwggidq
nuxi: 3.0.0
ofetch: 1.0.0
ohash: 1.0.0