refactor: removes copy-webpack-plugin (#21200)

This commit is contained in:
Omar López authored and GitHub committed 2025-05-09 01:01:53 +00:00
1 parent 80fa172f79
commit bccffb328b
4 files changed
+38 -90

No files matched your search

-23
View File
@@ -1,6 +1,4 @@
require("dotenv").config({ path: "../../.env" });
const CopyWebpackPlugin = require("copy-webpack-plugin");
const os = require("os");
const englishTranslation = require("./public/static/locales/en/common.json");
const { withAxiom } = require("next-axiom");
const { withSentryConfig } = require("@sentry/nextjs");
@@ -250,27 +248,6 @@ const nextConfig = {
})
);
config.plugins.push(
new CopyWebpackPlugin({
patterns: [
{
from: "../../packages/app-store/**/static/**",
to({ context, absoluteFilename }) {
// Adds compatibility for windows path
if (os.platform() === "win32") {
const absoluteFilenameWin = absoluteFilename.replaceAll("\\", "/");
const contextWin = context.replaceAll("\\", "/");
const appName = /app-store\/(.*)\/static/.exec(absoluteFilenameWin);
return Promise.resolve(`${contextWin}/public/app-store/${appName[1]}/[name][ext]`);
}
const appName = /app-store\/(.*)\/static/.exec(absoluteFilename);
return Promise.resolve(`${context}/public/app-store/${appName[1]}/[name][ext]`);
},
},
],
})
);
config.plugins.push(new webpack.DefinePlugin({ "process.env.BUILD_ID": JSON.stringify(buildId) }));
config.resolve.fallback = {
+4 -3
View File
@@ -7,14 +7,15 @@
"analyze:server": "BUNDLE_ANALYZE=server next build",
"analyze:browser": "BUNDLE_ANALYZE=browser next build",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next",
"dev": "next dev --turbopack",
"dev": "yarn copy-static && next dev --turbopack",
"dev:cron": "ts-node cron-tester.ts",
"dev-https": "NODE_TLS_REJECT_UNAUTHORIZED=0 next dev --experimental-https",
"dx": "yarn dev",
"test-codegen": "yarn playwright codegen http://localhost:3000",
"type-check": "tsc --pretty --noEmit",
"type-check:ci": "tsc-absolute --pretty --noEmit",
"build": "next build",
"copy-static": "node scripts/copy-app-store-static.js",
"build": "yarn copy-static && next build",
"start": "next start",
"lint": "eslint . --ignore-path .gitignore",
"lint:fix": "eslint . --ext .ts,.js,.tsx,.jsx --fix",
@@ -179,10 +180,10 @@
"@types/stripe": "^8.0.417",
"@types/uuid": "8.3.1",
"autoprefixer": "^10.4.12",
"copy-webpack-plugin": "^11.0.0",
"cron": "^3.1.7",
"detect-port": "^1.3.0",
"env-cmd": "^10.1.0",
"glob": "^10.3.10",
"google-auth-library": "^9.15.0",
"module-alias": "^2.2.2",
"msw": "^0.42.3",
+31
View File
@@ -0,0 +1,31 @@
const fs = require("fs");
const path = require("path");
const glob = require("glob");
const copyAppStoreStatic = () => {
// Get all static files from app-store packages
const staticFiles = glob.sync("../../packages/app-store/**/static/**/*", { nodir: true });
staticFiles.forEach((file) => {
// Extract app name from path
const appNameMatch = file.match(/app-store\/(.*?)\/static/);
if (!appNameMatch) return;
const appName = appNameMatch[1];
const fileName = path.basename(file);
// Create destination directory if it doesn't exist
const destDir = path.join(process.cwd(), "public", "app-store", appName);
if (!fs.existsSync(destDir)) {
fs.mkdirSync(destDir, { recursive: true });
}
// Copy file to destination
const destPath = path.join(destDir, fileName);
fs.copyFileSync(file, destPath);
console.log(`Copied ${file} to ${destPath}`);
});
};
// Run the copy function
copyAppStoreStatic();