From 9337c4b1d54e6d70c792a4312182dd73dfddc6f8 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Wed, 11 Mar 2026 11:27:34 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(frontend)=20adapt=20emoji=20?= =?UTF-8?q?copying=20to=20turbopack=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were previously copying the emoji assets in a webpack plugin, but that doesn't run with turbopack. This commit moves the copying to a pre-build script, which runs regardless of the bundler used. --- src/frontend/apps/impress/next.config.js | 18 ----------------- src/frontend/apps/impress/package.json | 1 - .../apps/impress/scripts/copy-emoji.mjs | 20 +++++++++++++++++++ .../apps/impress/scripts/prebuild.mjs | 1 + src/frontend/yarn.lock | 17 +++------------- 5 files changed, 24 insertions(+), 33 deletions(-) create mode 100644 src/frontend/apps/impress/scripts/copy-emoji.mjs diff --git a/src/frontend/apps/impress/next.config.js b/src/frontend/apps/impress/next.config.js index 13d7053f..069b1982 100644 --- a/src/frontend/apps/impress/next.config.js +++ b/src/frontend/apps/impress/next.config.js @@ -1,7 +1,5 @@ const crypto = require('crypto'); -const path = require('path'); -const CopyPlugin = require('copy-webpack-plugin'); const { InjectManifest } = require('workbox-webpack-plugin'); const buildId = crypto.randomBytes(256).toString('hex').slice(0, 8); @@ -54,22 +52,6 @@ const nextConfig = { }, ); - // Copy necessary fonts from node_modules to public directory during build or dev - config.plugins.push( - new CopyPlugin({ - patterns: [ - { - from: path.resolve( - __dirname, - '../../node_modules/emoji-datasource-apple/img/apple/64', - ), - to: path.resolve(__dirname, 'public/assets/fonts/emoji'), - force: true, - }, - ], - }), - ); - if (!isServer && process.env.NEXT_PUBLIC_SW_DEACTIVATED !== 'true') { config.plugins.push( new InjectManifest({ diff --git a/src/frontend/apps/impress/package.json b/src/frontend/apps/impress/package.json index f39ce387..79916349 100644 --- a/src/frontend/apps/impress/package.json +++ b/src/frontend/apps/impress/package.json @@ -93,7 +93,6 @@ "@types/react": "*", "@types/react-dom": "*", "@vitejs/plugin-react": "5.1.4", - "copy-webpack-plugin": "13.0.1", "cross-env": "10.1.0", "dotenv": "17.3.1", "eslint-plugin-docs": "*", diff --git a/src/frontend/apps/impress/scripts/copy-emoji.mjs b/src/frontend/apps/impress/scripts/copy-emoji.mjs new file mode 100644 index 00000000..fcc3d5be --- /dev/null +++ b/src/frontend/apps/impress/scripts/copy-emoji.mjs @@ -0,0 +1,20 @@ +/** + * Copies Apple emoji images from emoji-datasource-apple into the public directory. + * Used as a pre-step for both `dev` (Turbopack) and `build` (webpack) so that + * neither pipeline needs a webpack CopyPlugin for this purpose. + */ +import { cpSync } from 'fs'; +import { resolve, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +const src = resolve( + __dirname, + '../../../node_modules/emoji-datasource-apple/img/apple/64', +); +const dest = resolve(__dirname, '../public/assets/fonts/emoji'); + +cpSync(src, dest, { recursive: true, force: true }); + +console.log('✔ Emoji assets copied to public/assets/fonts/emoji'); diff --git a/src/frontend/apps/impress/scripts/prebuild.mjs b/src/frontend/apps/impress/scripts/prebuild.mjs index ccd69bb8..c729b0d9 100644 --- a/src/frontend/apps/impress/scripts/prebuild.mjs +++ b/src/frontend/apps/impress/scripts/prebuild.mjs @@ -2,3 +2,4 @@ * Pre-build script: runs all setup tasks required before `next build`. * Add future build preparation steps here. */ +import './copy-emoji.mjs'; diff --git a/src/frontend/yarn.lock b/src/frontend/yarn.lock index f4defae9..40ab1638 100644 --- a/src/frontend/yarn.lock +++ b/src/frontend/yarn.lock @@ -9078,17 +9078,6 @@ cookiejar@^2.1.4: resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.4.tgz#ee669c1fea2cf42dc31585469d193fef0d65771b" integrity sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw== -copy-webpack-plugin@13.0.1: - version "13.0.1" - resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-13.0.1.tgz#fba18c22bcab3633524e1b652580ff4489eddc0d" - integrity sha512-J+YV3WfhY6W/Xf9h+J1znYuqTye2xkBUIGyTPWuBAT27qajBa5mR4f8WBmfDY3YjRftT2kqZZiLi1qf0H+UOFw== - dependencies: - glob-parent "^6.0.1" - normalize-path "^3.0.0" - schema-utils "^4.2.0" - serialize-javascript "^6.0.2" - tinyglobby "^0.2.12" - core-js-compat@^3.43.0: version "3.46.0" resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.46.0.tgz#0c87126a19a1af00371e12b02a2b088a40f3c6f7" @@ -10741,7 +10730,7 @@ glob-parent@^5.1.2, glob-parent@~5.1.2: dependencies: is-glob "^4.0.1" -glob-parent@^6.0.1, glob-parent@^6.0.2: +glob-parent@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== @@ -15192,7 +15181,7 @@ scheduler@^0.27.0: resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.27.0.tgz#0c4ef82d67d1e5c1e359e8fc76d3a87f045fe5bd" integrity sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q== -schema-utils@^4.2.0, schema-utils@^4.3.0, schema-utils@^4.3.3: +schema-utils@^4.3.0, schema-utils@^4.3.3: version "4.3.3" resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-4.3.3.tgz#5b1850912fa31df90716963d45d9121fdfc09f46" integrity sha512-eflK8wEtyOE6+hsaRVPxvUKYCpRgzLqDTb8krvAsRIwOGlHoSgYLgBXoubGgLd2fT41/OUYdb48v4k4WWHQurA== @@ -16070,7 +16059,7 @@ tinyexec@^1.0.2: resolved "https://registry.yarnpkg.com/tinyexec/-/tinyexec-1.0.2.tgz#bdd2737fe2ba40bd6f918ae26642f264b99ca251" integrity sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg== -tinyglobby@^0.2.12, tinyglobby@^0.2.13, tinyglobby@^0.2.15: +tinyglobby@^0.2.13, tinyglobby@^0.2.15: version "0.2.15" resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.15.tgz#e228dd1e638cea993d2fdb4fcd2d4602a79951c2" integrity sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==