Skip to content

Commit

Permalink
fix(misskey-dev#10609): remove isChromatic on real build (misskey-dev…
Browse files Browse the repository at this point in the history
…#10613)

* perf: remove isChromatic on real build

* revert: Revert misskey-dev#10475 in MkTime

This reverts commit 7d11cf8.

* @rollup/plugin-replace as dependencies

* fix pnpm-lock,yaml

---------

Co-authored-by: tamaina <[email protected]>
  • Loading branch information
2 people authored and na2na-p committed May 10, 2023
1 parent 5a8c784 commit 3f7947c
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 72 deletions.
6 changes: 5 additions & 1 deletion packages/frontend/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolve } from 'node:path';
import type { StorybookConfig } from '@storybook/vue3-vite';
import { mergeConfig } from 'vite';
import { type Plugin, mergeConfig } from 'vite';
import turbosnap from 'vite-plugin-turbosnap';
const config = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
Expand All @@ -22,6 +22,10 @@ const config = {
disableTelemetry: true,
},
async viteFinal(config) {
const replacePluginForIsChromatic = config.plugins?.findIndex((plugin) => plugin && (plugin as Partial<Plugin>)?.name === 'replace') ?? -1;
if (~replacePluginForIsChromatic) {
config.plugins?.splice(replacePluginForIsChromatic, 1);
}
return mergeConfig(config, {
plugins: [
turbosnap({
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@discordapp/twemoji": "14.1.2",
"@rollup/plugin-alias": "4.0.3",
"@rollup/plugin-json": "6.0.0",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/pluginutils": "5.0.2",
"@syuilo/aiscript": "0.13.1",
"@tabler/icons-webfont": "2.12.0",
Expand All @@ -32,6 +33,7 @@
"chartjs-chart-matrix": "2.0.1",
"chartjs-plugin-gradient": "0.6.1",
"chartjs-plugin-zoom": "2.0.1",
"chromatic": "6.17.3",
"compare-versions": "5.0.1",
"cropperjs": "2.0.0-beta.2",
"date-fns": "2.29.3",
Expand Down Expand Up @@ -116,7 +118,6 @@
"@vue/runtime-core": "3.2.47",
"astring": "1.8.4",
"chokidar-cli": "3.0.0",
"chromatic": "6.17.3",
"cross-env": "7.0.3",
"cypress": "12.9.0",
"eslint": "8.37.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/components/global/MkTime.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</template>

<script lang="ts" setup>
import isChromatic from 'chromatic/isChromatic';
import { onUnmounted } from 'vue';
import { i18n } from '@/i18n';
import { dateTimeFormat } from '@/scripts/intl-const';
Expand All @@ -17,7 +18,7 @@ const props = withDefaults(defineProps<{
origin?: Date | null;
mode?: 'relative' | 'absolute' | 'detail';
}>(), {
origin: null,
origin: isChromatic() ? new Date('2023-04-01T00:00:00Z') : null,
mode: 'relative',
});
Expand Down
11 changes: 11 additions & 0 deletions packages/frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path';
import pluginReplace from '@rollup/plugin-replace';
import pluginVue from '@vitejs/plugin-vue';
import { type UserConfig, defineConfig } from 'vite';

Expand Down Expand Up @@ -46,6 +47,16 @@ export function getConfig(): UserConfig {
reactivityTransform: true,
}),
pluginJson5(),
...process.env.NODE_ENV === 'production'
? [
pluginReplace({
preventAssignment: true,
values: {
'isChromatic()': JSON.stringify(false),
},
}),
]
: [],
],

resolve: {
Expand Down
Loading

0 comments on commit 3f7947c

Please sign in to comment.