Compare commits

..

No commits in common. "3e5054d1ec9563484c8eacddcfc016d5f5f64789" and "a753351fa5808b1e94bc09ca73da8e8a268a1fe2" have entirely different histories.

2 changed files with 22 additions and 15 deletions

View file

@ -27,13 +27,12 @@ export const devSwPlugin = ({ swSrc, swDest, transformSW, alias }) => {
Object.entries(alias).forEach(([source, dest]) => {
esbuildAlias[source] = dest.startsWith('/') ? projectRoot + dest : dest
})
let localConfig
return {
name: 'dev-sw-plugin',
apply: 'serve',
configResolved(config) {
localConfig = config
configResolved() {
/* no-op */
},
resolveId(id) {
const name = id.startsWith('/') ? id.slice(1) : id
@ -58,13 +57,9 @@ export const devSwPlugin = ({ swSrc, swDest, transformSW, alias }) => {
* https://bugzilla.mozilla.org/show_bug.cgi?id=1360870
*/
async transform(code, id) {
if (id === swFullSrc) {
if (id === swFullSrc && transformSW) {
const res = await esbuild.build({
entryPoints: [swSrc],
define: {
'process.env': JSON.stringify(localConfig.define['process.env']),
'COMMIT_HASH': JSON.stringify(localConfig.define['COMMIT_HASH']),
},
bundle: true,
write: false,
outfile: 'sw-pleroma.js',
@ -140,17 +135,16 @@ export const buildSwPlugin = ({ swSrc, swDest }) => {
publicDir: false,
build: {
...resolvedConfig.build,
lib: {
entry: swSrc,
formats: ['iife'],
name: 'sw_pleroma',
},
emptyOutDir: false,
rolldownOptions: {
input: {
main: swSrc
},
context: 'self',
output: {
entryFileNames: swDest,
codeSplitting: false,
format: 'iife',
}
},
},
},
configFile: false,

View file

@ -165,6 +165,18 @@ export default defineConfig(async ({ mode, command }) => {
}),
...(mode === 'test' ? [mswPlugin()] : []),
],
optimizeDeps: {
// For unknown reasons, during vitest, vite will re-optimize the following
// deps, causing the test to reload, so add them here so that it will not
// reload during tests
include: [
'custom-event-polyfill',
'vue-i18n',
'@ungap/event-target',
'body-scroll-lock',
'@kazvmoe-infra/pinch-zoom-element',
],
},
css: {
devSourcemap: true,
transformer: 'lightningcss',
@ -198,6 +210,7 @@ export default defineConfig(async ({ mode, command }) => {
main: 'index.html',
},
output: {
inlineDynamicImports: false,
entryFileNames(chunkInfo) {
const id = chunkInfo.facadeModuleId
if (id.endsWith(swSrc)) {