replace icons in embeds

This commit is contained in:
dakkar 2024-10-10 13:50:20 +01:00
parent 7628fe9c46
commit a2d47f686f
2 changed files with 7 additions and 8 deletions

View file

@ -630,9 +630,9 @@ seems to do a decent job)
* check the changes against our `develop` (`git diff develop`) and * check the changes against our `develop` (`git diff develop`) and
against Misskey (`git diff misskey/develop`) against Misskey (`git diff misskey/develop`)
* re-generate `misskey-js` (`pnpm build-misskey-js-with-types`) and commit * re-generate `misskey-js` (`pnpm build-misskey-js-with-types`) and commit
* build the frontend: `rm -rf built/; NODE_ENV=development pnpm --filter=frontend * build the frontend: `rm -rf built/; NODE_ENV=development pnpm
build` (the `development` tells it to keep some of the original --filter=frontend --filter=frontend-embed build` (the `development`
filenames in the built files) tells it to keep some of the original filenames in the built files)
* make sure there aren't any new `ti-*` classes (Tabler Icons), and * make sure there aren't any new `ti-*` classes (Tabler Icons), and
replace them with appropriate `ph-*` ones (Phosphor Icons): replace them with appropriate `ph-*` ones (Phosphor Icons):
`grep -rP '["'\'']ti[ -](?!fw)' -- built/` should show you what to change. `grep -rP '["'\'']ti[ -](?!fw)' -- built/` should show you what to change.

View file

@ -6,6 +6,7 @@ import locales from '../../locales/index.js';
import meta from '../../package.json'; import meta from '../../package.json';
import packageInfo from './package.json' with { type: 'json' }; import packageInfo from './package.json' with { type: 'json' };
import pluginJson5 from './vite.json5.js'; import pluginJson5 from './vite.json5.js';
import { pluginReplaceIcons } from '../frontend/vite.replaceIcons.ts';
const extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json', '.json5', '.svg', '.sass', '.scss', '.css', '.vue']; const extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json', '.json5', '.svg', '.sass', '.scss', '.css', '.vue'];
@ -68,6 +69,7 @@ export function getConfig(): UserConfig {
plugins: [ plugins: [
pluginVue(), pluginVue(),
pluginJson5(), pluginJson5(),
...pluginReplaceIcons(),
], ],
resolve: { resolve: {
@ -84,11 +86,8 @@ export function getConfig(): UserConfig {
modules: { modules: {
generateScopedName(name, filename, _css): string { generateScopedName(name, filename, _css): string {
const id = (path.relative(__dirname, filename.split('?')[0]) + '-' + name).replace(/[\\\/\.\?&=]/g, '-').replace(/(src-|vue-)/g, ''); const id = (path.relative(__dirname, filename.split('?')[0]) + '-' + name).replace(/[\\\/\.\?&=]/g, '-').replace(/(src-|vue-)/g, '');
if (process.env.NODE_ENV === 'production') { const shortId = id.replace(/^(components(-global)?|widgets|ui(-_common_)?)-/, '');
return 'x' + toBase62(hash(id)).substring(0, 4); return shortId + '-' + toBase62(hash(id)).substring(0, 4);
} else {
return id;
}
}, },
}, },
}, },