bigbuffet-rw/vite.config.ts

94 lines
2.3 KiB
TypeScript
Raw Normal View History

/// <reference types="vitest" />
import { fileURLToPath, URL } from 'node:url';
2023-09-13 10:04:17 -07:00
import react from '@vitejs/plugin-react';
import { visualizer } from 'rollup-plugin-visualizer';
2023-09-13 10:04:17 -07:00
import { defineConfig } from 'vite';
import compileTime from 'vite-plugin-compile-time';
import { createHtmlPlugin } from 'vite-plugin-html';
2023-09-15 12:37:09 -07:00
import { VitePWA } from 'vite-plugin-pwa';
2023-09-13 10:04:17 -07:00
import vitePluginRequire from 'vite-plugin-require';
import { viteStaticCopy } from 'vite-plugin-static-copy';
export default defineConfig({
root: 'src',
2023-09-13 10:04:17 -07:00
build: {
// Relative to the root
outDir: '../dist',
2023-09-13 10:04:17 -07:00
assetsDir: 'packs',
assetsInlineLimit: 0,
2023-09-14 17:14:16 -07:00
rollupOptions: {
output: {
assetFileNames: 'packs/assets/[name]-[hash].[ext]',
chunkFileNames: 'packs/js/[name]-[hash].js',
entryFileNames: 'packs/[name]-[hash].js',
},
},
2023-09-13 10:04:17 -07:00
},
2023-09-13 10:24:49 -07:00
server: {
port: 3036,
},
2023-09-13 10:04:17 -07:00
plugins: [
// @ts-ignore
vitePluginRequire.default(),
2023-09-15 12:37:09 -07:00
compileTime(),
2023-09-13 10:04:17 -07:00
createHtmlPlugin({
template: 'index.html',
minify: {
collapseWhitespace: true,
removeComments: false,
},
2023-09-13 10:04:17 -07:00
}),
react({
// Use React plugin in all *.jsx and *.tsx files
include: '**/*.{jsx,tsx}',
2023-09-13 14:35:41 -07:00
babel: {
configFile: './babel.config.cjs',
},
2023-09-13 10:04:17 -07:00
}),
2023-09-15 12:37:09 -07:00
VitePWA({
injectRegister: null,
strategies: 'injectManifest',
injectManifest: {
injectionPoint: undefined,
plugins: [
// @ts-ignore
compileTime(),
],
},
manifestFilename: 'manifest.json',
manifest: {
name: 'Soapbox',
short_name: 'Soapbox',
description: 'A social media frontend with a focus on custom branding and ease of use.',
},
srcDir: 'service-worker',
2023-09-15 12:37:09 -07:00
filename: 'sw.ts',
}),
2023-09-13 10:04:17 -07:00
viteStaticCopy({
targets: [{
src: '../node_modules/twemoji/assets/svg/*',
dest: 'packs/emoji/',
}],
}),
visualizer({
emitFile: true,
filename: 'report.html',
title: 'Soapbox Bundle',
}),
2023-09-13 10:04:17 -07:00
],
resolve: {
alias: [
{ find: 'soapbox', replacement: fileURLToPath(new URL('./src', import.meta.url)) },
2023-09-13 10:04:17 -07:00
],
},
assetsInclude: ['**/*.oga'],
test: {
globals: true,
environment: 'jsdom',
cache: {
dir: '../node_modules/.vitest',
},
setupFiles: 'jest/test-setup.ts',
},
2023-09-13 10:04:17 -07:00
});