Do some more dumb shit

vite-sw
Alex Gleason 2023-09-14 20:37:49 -05:00
rodzic 1ebe3ce48e
commit f1dd87ba21
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 19 dodań i 3 usunięć

1
.gitignore vendored
Wyświetl plik

@ -9,6 +9,7 @@
/.vs/
yarn-error.log*
/junit.xml
*.timestamp-*
/static/
/static-test/

Wyświetl plik

@ -1,12 +1,23 @@
import path from 'path';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import { defineConfig, type Plugin } from 'vite';
import compileTime from 'vite-plugin-compile-time';
import { createHtmlPlugin } from 'vite-plugin-html';
import vitePluginRequire from 'vite-plugin-require';
import { viteStaticCopy } from 'vite-plugin-static-copy';
const removeExportsPlugin: Plugin = {
name: 'remove-sw-exports',
generateBundle(_options, bundle) {
for (const [name, chunk] of Object.entries(bundle)) {
if (chunk.type === 'chunk' && name === 'sw.js') {
chunk.code = chunk.code.replace(/export{.*};\s*$/g, '');
}
}
},
};
export default defineConfig({
root: 'app',
build: {
@ -27,8 +38,11 @@ export default defineConfig({
return 'packs/[name]-[hash].js';
}
},
manualChunks: {
'sw': ['app/soapbox/service-worker/sw.ts'],
manualChunks: (id) => {
if (id.includes('soapbox/service-worker')) {
return 'sw';
}
return 'main';
},
assetFileNames: 'packs/assets/[name]-[hash].[ext]',
chunkFileNames: 'packs/js/[name]-[hash].js',
@ -58,6 +72,7 @@ export default defineConfig({
dest: 'packs/emoji/',
}],
}),
removeExportsPlugin,
],
resolve: {
alias: [