From ec8905f81c838a96700d3eb2522bfda5fd1b3931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Sat, 1 Apr 2023 18:18:11 +0900 Subject: [PATCH] build(#10336): staticify assets --- packages/frontend/.storybook/main.ts | 12 +++++++++++- packages/frontend/.storybook/preview-head.html | 2 +- packages/frontend/.storybook/preview.ts | 3 --- packages/frontend/package.json | 1 + pnpm-lock.yaml | 16 ++++++++++++++++ 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/packages/frontend/.storybook/main.ts b/packages/frontend/.storybook/main.ts index 72c2490a43..4b5f7260e2 100644 --- a/packages/frontend/.storybook/main.ts +++ b/packages/frontend/.storybook/main.ts @@ -1,6 +1,7 @@ import { resolve } from 'node:path'; import type { StorybookConfig } from '@storybook/vue3-vite'; import { mergeConfig } from 'vite'; +import { viteStaticCopy } from 'vite-plugin-static-copy'; const config = { stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], addons: [ @@ -22,7 +23,16 @@ const config = { }, async viteFinal(config, options) { return mergeConfig(config, { - assetsInclude: [resolve(__dirname, '../node_modules/@tabler/icons-webfont/**/*.{css,eot,ttf,woff,woff2}')], + plugins: [ + viteStaticCopy({ + targets: [ + { + src: resolve(__dirname, '../node_modules/@tabler/icons-webfont/**/*.{css,eot,ttf,woff,woff2}'), + dest: 'node_modules/@tabler/icons-webfont', + }, + ], + }), + ], build: { target: [ 'chrome108', diff --git a/packages/frontend/.storybook/preview-head.html b/packages/frontend/.storybook/preview-head.html index d0ec5b452f..dbbc2e54f7 100644 --- a/packages/frontend/.storybook/preview-head.html +++ b/packages/frontend/.storybook/preview-head.html @@ -1,4 +1,4 @@ - + diff --git a/packages/frontend/.storybook/preview.ts b/packages/frontend/.storybook/preview.ts index 1543552980..0035362058 100644 --- a/packages/frontend/.storybook/preview.ts +++ b/packages/frontend/.storybook/preview.ts @@ -7,9 +7,6 @@ import { commonHandlers, onUnhandledRequest } from './mocks'; import themes from './themes'; import '../src/style.scss'; -// TODO: HMR が壊れているのを直す -import.meta.hot.invalidate(); - const appInitialized = Symbol(); let moduleInitialized = false; diff --git a/packages/frontend/package.json b/packages/frontend/package.json index f0c92ff5bf..e541295223 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -129,6 +129,7 @@ "storybook": "7.0.0-rc.10", "storybook-addon-misskey-theme": "github:misskey-dev/storybook-addon-misskey-theme", "summaly": "github:misskey-dev/summaly", + "vite-plugin-static-copy": "^0.13.1", "vitest": "^0.29.8", "vitest-fetch-mock": "^0.2.2", "vue-eslint-parser": "9.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 86e03c4e4f..ff4619994f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -931,6 +931,9 @@ importers: summaly: specifier: github:misskey-dev/summaly version: github.com/misskey-dev/summaly/1bab7afee616429b8bbf7a7cbcbb8ebcef66d992 + vite-plugin-static-copy: + specifier: ^0.13.1 + version: 0.13.1(vite@4.2.1) vitest: specifier: ^0.29.8 version: 0.29.8(happy-dom@8.9.0)(sass@1.60.0) @@ -19780,6 +19783,19 @@ packages: - terser dev: true + /vite-plugin-static-copy@0.13.1(vite@4.2.1): + resolution: {integrity: sha512-KwIcGBT1aOxSq+laK3VmSngoEa3HXWj/6ZEXdv+y59eZ7p/XSuPahoDo+CfYW22JjTdnstgeKWiX+78KNgDu6g==} + engines: {node: ^14.18.0 || >=16.0.0} + peerDependencies: + vite: ^3.0.0 || ^4.0.0 + dependencies: + chokidar: 3.5.3 + fast-glob: 3.2.12 + fs-extra: 11.1.0 + picocolors: 1.0.0 + vite: 4.2.1(@types/node@18.15.11)(sass@1.60.0) + dev: true + /vite@4.2.1(@types/node@18.15.11)(sass@1.60.0): resolution: {integrity: sha512-7MKhqdy0ISo4wnvwtqZkjke6XN4taqQ2TBaTccLIpOKv7Vp2h4Y+NpmWCnGDeSvvn45KxvWgGyb0MkHvY1vgbg==} engines: {node: ^14.18.0 || >=16.0.0}