2023-09-15 21:24:01 +00:00
|
|
|
/// <reference types="vitest" />
|
2023-09-13 17:04:17 +00:00
|
|
|
import path from 'path';
|
|
|
|
|
|
|
|
import react from '@vitejs/plugin-react';
|
2023-09-16 04:05:58 +00:00
|
|
|
import { visualizer } from 'rollup-plugin-visualizer';
|
2023-09-13 17:04:17 +00:00
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
import compileTime from 'vite-plugin-compile-time';
|
|
|
|
import { createHtmlPlugin } from 'vite-plugin-html';
|
2023-09-15 19:37:09 +00:00
|
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
2023-09-13 17:04:17 +00:00
|
|
|
import vitePluginRequire from 'vite-plugin-require';
|
|
|
|
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
root: 'app',
|
|
|
|
build: {
|
|
|
|
// Relative to the root
|
|
|
|
outDir: '../static',
|
|
|
|
assetsDir: 'packs',
|
2023-09-15 00:04:07 +00:00
|
|
|
assetsInlineLimit: 0,
|
2023-09-15 00:14:16 +00:00
|
|
|
rollupOptions: {
|
|
|
|
output: {
|
|
|
|
assetFileNames: 'packs/assets/[name]-[hash].[ext]',
|
|
|
|
chunkFileNames: 'packs/js/[name]-[hash].js',
|
|
|
|
entryFileNames: 'packs/[name]-[hash].js',
|
|
|
|
},
|
|
|
|
},
|
2023-09-13 17:04:17 +00:00
|
|
|
},
|
2023-09-13 17:24:49 +00:00
|
|
|
server: {
|
|
|
|
port: 3036,
|
|
|
|
},
|
2023-09-13 17:04:17 +00:00
|
|
|
plugins: [
|
|
|
|
// @ts-ignore
|
|
|
|
vitePluginRequire.default(),
|
2023-09-15 19:37:09 +00:00
|
|
|
compileTime(),
|
2023-09-13 17:04:17 +00:00
|
|
|
createHtmlPlugin({
|
|
|
|
template: 'index.html',
|
2023-09-16 03:38:29 +00:00
|
|
|
minify: {
|
|
|
|
collapseWhitespace: true,
|
|
|
|
removeComments: false,
|
|
|
|
},
|
2023-09-13 17:04:17 +00:00
|
|
|
}),
|
|
|
|
react({
|
|
|
|
// Use React plugin in all *.jsx and *.tsx files
|
|
|
|
include: '**/*.{jsx,tsx}',
|
2023-09-13 21:35:41 +00:00
|
|
|
babel: {
|
|
|
|
configFile: './babel.config.cjs',
|
|
|
|
},
|
2023-09-13 17:04:17 +00:00
|
|
|
}),
|
2023-09-15 19:37:09 +00: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: 'soapbox/service-worker',
|
|
|
|
filename: 'sw.ts',
|
|
|
|
}),
|
2023-09-13 17:04:17 +00:00
|
|
|
viteStaticCopy({
|
|
|
|
targets: [{
|
|
|
|
src: '../node_modules/twemoji/assets/svg/*',
|
|
|
|
dest: 'packs/emoji/',
|
|
|
|
}],
|
|
|
|
}),
|
2023-09-16 04:05:58 +00:00
|
|
|
visualizer({
|
|
|
|
emitFile: true,
|
|
|
|
filename: 'report.html',
|
|
|
|
title: 'Soapbox Bundle',
|
|
|
|
}),
|
2023-09-13 17:04:17 +00:00
|
|
|
],
|
|
|
|
resolve: {
|
|
|
|
alias: [
|
|
|
|
{ find: 'soapbox', replacement: path.resolve(__dirname, 'app', 'soapbox') },
|
|
|
|
{ find: 'assets', replacement: path.resolve(__dirname, 'app', 'assets') },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
assetsInclude: ['**/*.oga'],
|
2023-09-15 21:24:01 +00:00
|
|
|
test: {
|
|
|
|
globals: true,
|
|
|
|
environment: 'jsdom',
|
2023-09-15 22:19:13 +00:00
|
|
|
cache: {
|
|
|
|
dir: '../node_modules/.vitest',
|
|
|
|
},
|
2023-09-15 21:24:01 +00:00
|
|
|
},
|
2023-09-13 17:04:17 +00:00
|
|
|
});
|