Merge commit 'd78535eab9cefc285c0d7ef88adb125ab1ceb6bd' into glitch-soc/merge-upstream

Conflicts:
- `vite.config.mts`:
  Upstream moved its theming system to a plug-in, where we had our own.
  Adapted the file as well as our own plugin to adopt the same mechanisms.
This commit is contained in:
Claire
2025-05-27 20:49:19 +02:00
125 changed files with 994 additions and 454 deletions
+2 -33
View File
@@ -1,4 +1,3 @@
import fs from 'node:fs/promises';
import path from 'node:path';
import { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';
@@ -9,7 +8,6 @@ import { visualizer } from 'rollup-plugin-visualizer';
import RailsPlugin from 'vite-plugin-rails';
import { VitePWA } from 'vite-plugin-pwa';
import tsconfigPaths from 'vite-tsconfig-paths';
import yaml from 'js-yaml';
import legacy from '@vitejs/plugin-legacy';
import { defineConfig, UserConfigFnPromise, UserConfig } from 'vite';
@@ -17,39 +15,11 @@ import postcssPresetEnv from 'postcss-preset-env';
import { MastodonServiceWorkerLocales } from './config/vite/plugin-sw-locales';
import { MastodonEmojiCompressed } from './config/vite/plugin-emoji-compressed';
import { GlitchThemesPlugin } from './config/vite/plugin-glitch-themes';
import { GlitchThemes } from './config/vite/plugin-glitch-themes';
const jsRoot = path.resolve(__dirname, 'app/javascript');
// NOTE: disabled in glitch-soc
// const themesFile = path.resolve(__dirname, 'config/themes.yml');
export const config: UserConfigFnPromise = async ({ mode, command }) => {
const entrypoints: Record<string, string> = {}; // All JS entrypoints are taken care of by Vite Ruby
/* NOTE: disabled in glitch-soc
// Get all files mentioned in the themes.yml file.
const themesString = await fs.readFile(themesFile, 'utf8');
const themes = yaml.load(themesString, {
filename: 'themes.yml',
schema: yaml.FAILSAFE_SCHEMA,
});
if (!themes || typeof themes !== 'object') {
throw new Error('Invalid themes.yml file');
}
for (const themePath of Object.values(themes)) {
if (
typeof themePath !== 'string' ||
themePath.split('.').length !== 2 || // Ensure it has exactly one period
!themePath.endsWith('css')
) {
console.warn(`Invalid theme path "${themePath}" in themes.yml, skipping`);
continue;
}
entrypoints[path.basename(themePath)] = path.resolve(jsRoot, themePath);
} */
return {
root: jsRoot,
css: {
@@ -75,7 +45,6 @@ export const config: UserConfigFnPromise = async ({ mode, command }) => {
chunkSizeWarningLimit: 1 * 1024 * 1024, // 1MB
sourcemap: true,
rollupOptions: {
input: entrypoints,
output: {
chunkFileNames({ facadeModuleId, name }) {
if (!facadeModuleId) {
@@ -116,12 +85,12 @@ export const config: UserConfigFnPromise = async ({ mode, command }) => {
manifestPaths: ['.vite/manifest.json', '.vite/manifest-assets.json'],
},
}),
GlitchThemes(),
react({
babel: {
plugins: ['formatjs', 'transform-react-remove-prop-types'],
},
}),
GlitchThemesPlugin(),
MastodonServiceWorkerLocales(),
MastodonEmojiCompressed(),
legacy({