mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 13:43:08 +02:00
59255e11b8
* #10781
* fix tsconfig
* fetch image??
* Revert "fetch image??"
This reverts commit 0925c28d5a4f328264c39d5591dc736795541683.
* wip
* Revert "wip"
This reverts commit be97c6cb88318bcea441edeeecb69b6d6ed0dd8f.
* loading="eager"
* loading="eager" 2
* error
* wip
* wip
* wip
* wip
* clean up
* fix
* 生成するworkerを1つにする?
* clean up
* use buraha
* wip
* smaller width, height
* update buraha
* clean up
* fix
* Update MkMediaImage.vue
* Update MkImgWithBlurhash.vue
* Revert "fix(frontend): センシティブ設定された画像を開くとき一瞬レイアウトが崩れる問題を修正"
This reverts commit 41e9aa6f9b
.
* Update MkMediaList.vue
* Update MkMediaList.vue
* Update MkMediaList.vue
* Update CHANGELOG.md
* wait for decode
* fix
* ?
* (test) remove container-type: inline-size;
* Revert "(test) remove container-type: inline-size;"
This reverts commit 9448e64228428175a3d624c04df1bfad0f59cb69.
* container-name
* Revert "container-name"
This reverts commit 94385d32213a00a06a59fbd2296d6ef1b5f91785.
* width: 100%;
* improve performance
* refactor
* wip
* WIP
* wip
* Revert "wip"
This reverts commit 36e3b75cab8114e423544b79a8e2df353880f43b.
* Revert "WIP"
This reverts commit 05b729ef9189aea052ba411ac10f30a46cc668c8.
* Revert "wip"
This reverts commit 0801e7936116c58154d7cecfea955dd15fa61a77.
* #10860
* wip
* no worker
* Revert "no worker"
This reverts commit a9c49e4fb49976958a7594393343d52be0e082d7.
* ✌️
* workerNumber固定は不要
---------
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
160 lines
4.1 KiB
TypeScript
160 lines
4.1 KiB
TypeScript
import path from 'path';
|
|
import pluginReplace from '@rollup/plugin-replace';
|
|
import pluginVue from '@vitejs/plugin-vue';
|
|
import { type UserConfig, defineConfig } from 'vite';
|
|
// @ts-expect-error https://github.com/sxzz/unplugin-vue-macros/issues/257#issuecomment-1410752890
|
|
import ReactivityTransform from '@vue-macros/reactivity-transform/vite';
|
|
|
|
import locales from '../../locales';
|
|
import meta from '../../package.json';
|
|
import pluginJson5 from './vite.json5';
|
|
|
|
const extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json', '.json5', '.svg', '.sass', '.scss', '.css', '.vue'];
|
|
|
|
const hash = (str: string, seed = 0): number => {
|
|
let h1 = 0xdeadbeef ^ seed,
|
|
h2 = 0x41c6ce57 ^ seed;
|
|
for (let i = 0, ch; i < str.length; i++) {
|
|
ch = str.charCodeAt(i);
|
|
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
}
|
|
|
|
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
|
|
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
|
};
|
|
|
|
const BASE62_DIGITS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
function toBase62(n: number): string {
|
|
if (n === 0) {
|
|
return '0';
|
|
}
|
|
let result = '';
|
|
while (n > 0) {
|
|
result = BASE62_DIGITS[n % BASE62_DIGITS.length] + result;
|
|
n = Math.floor(n / BASE62_DIGITS.length);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
export function getConfig(): UserConfig {
|
|
return {
|
|
base: '/vite/',
|
|
|
|
server: {
|
|
port: 5173,
|
|
},
|
|
|
|
plugins: [
|
|
pluginVue({
|
|
reactivityTransform: true,
|
|
}),
|
|
ReactivityTransform(),
|
|
pluginJson5(),
|
|
...process.env.NODE_ENV === 'production'
|
|
? [
|
|
pluginReplace({
|
|
preventAssignment: true,
|
|
values: {
|
|
'isChromatic()': JSON.stringify(false),
|
|
},
|
|
}),
|
|
]
|
|
: [],
|
|
],
|
|
|
|
resolve: {
|
|
extensions,
|
|
alias: {
|
|
'@/': __dirname + '/src/',
|
|
'/client-assets/': __dirname + '/assets/',
|
|
'/static-assets/': __dirname + '/../backend/assets/',
|
|
'/fluent-emojis/': __dirname + '/../../fluent-emojis/dist/',
|
|
'/fluent-emoji/': __dirname + '/../../fluent-emojis/dist/',
|
|
},
|
|
},
|
|
|
|
css: {
|
|
modules: {
|
|
generateScopedName(name, filename, _css): string {
|
|
const id = (path.relative(__dirname, filename.split('?')[0]) + '-' + name).replace(/[\\\/\.\?&=]/g, '-').replace(/(src-|vue-)/g, '');
|
|
if (process.env.NODE_ENV === 'production') {
|
|
return 'x' + toBase62(hash(id)).substring(0, 4);
|
|
} else {
|
|
return id;
|
|
}
|
|
},
|
|
},
|
|
},
|
|
|
|
define: {
|
|
_VERSION_: JSON.stringify(meta.version),
|
|
_LANGS_: JSON.stringify(Object.entries(locales).map(([k, v]) => [k, v._lang_])),
|
|
_ENV_: JSON.stringify(process.env.NODE_ENV),
|
|
_DEV_: process.env.NODE_ENV !== 'production',
|
|
_PERF_PREFIX_: JSON.stringify('Misskey:'),
|
|
_DATA_TRANSFER_DRIVE_FILE_: JSON.stringify('mk_drive_file'),
|
|
_DATA_TRANSFER_DRIVE_FOLDER_: JSON.stringify('mk_drive_folder'),
|
|
_DATA_TRANSFER_DECK_COLUMN_: JSON.stringify('mk_deck_column'),
|
|
__VUE_OPTIONS_API__: true,
|
|
__VUE_PROD_DEVTOOLS__: false,
|
|
},
|
|
|
|
// https://vitejs.dev/guide/dep-pre-bundling.html#monorepos-and-linked-dependencies
|
|
optimizeDeps: {
|
|
include: ['misskey-js'],
|
|
},
|
|
|
|
build: {
|
|
target: [
|
|
'chrome108',
|
|
'firefox109',
|
|
'safari16',
|
|
],
|
|
manifest: 'manifest.json',
|
|
rollupOptions: {
|
|
input: {
|
|
app: './src/_boot_.ts',
|
|
},
|
|
output: {
|
|
manualChunks: {
|
|
vue: ['vue'],
|
|
photoswipe: ['photoswipe', 'photoswipe/lightbox', 'photoswipe/style.css'],
|
|
},
|
|
},
|
|
},
|
|
cssCodeSplit: true,
|
|
outDir: __dirname + '/../../built/_vite_',
|
|
assetsDir: '.',
|
|
emptyOutDir: false,
|
|
sourcemap: process.env.NODE_ENV === 'development',
|
|
reportCompressedSize: false,
|
|
|
|
// https://vitejs.dev/guide/dep-pre-bundling.html#monorepos-and-linked-dependencies
|
|
commonjsOptions: {
|
|
include: [/misskey-js/, /node_modules/],
|
|
},
|
|
},
|
|
|
|
worker: {
|
|
format: 'es',
|
|
},
|
|
|
|
test: {
|
|
environment: 'happy-dom',
|
|
deps: {
|
|
inline: [
|
|
// XXX: misskey-dev/browser-image-resizer has no "type": "module"
|
|
'browser-image-resizer',
|
|
],
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
const config = defineConfig(({ command, mode }) => getConfig());
|
|
|
|
export default config;
|