@salesforce/webapp-template-base-react-app-experimental 1.22.0 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/package.json +7 -3
- package/src/force-app/main/default/webapplications/base-react-app/build/vite.config.d.ts +2 -0
- package/src/force-app/main/default/webapplications/base-react-app/build/vite.config.js +73 -0
- package/src/force-app/main/default/webapplications/base-react-app/e2e/app.spec.ts +24 -0
- package/src/force-app/main/default/webapplications/base-react-app/package-lock.json +7157 -0
- package/src/force-app/main/default/webapplications/base-react-app/package.json +4 -1
- package/src/force-app/main/default/webapplications/base-react-app/playwright.config.ts +24 -0
- package/src/force-app/main/default/webapplications/base-react-app/scripts/rewrite-e2e-assets.mjs +23 -0
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
8
8
|
"build": "tsc -b && vite build",
|
|
9
|
+
"build:e2e": "npm run build && node scripts/rewrite-e2e-assets.mjs",
|
|
9
10
|
"lint": "eslint .",
|
|
10
11
|
"preview": "vite preview",
|
|
11
12
|
"test": "vitest"
|
|
@@ -37,6 +38,8 @@
|
|
|
37
38
|
"typescript": "~5.9.3",
|
|
38
39
|
"typescript-eslint": "^8.46.4",
|
|
39
40
|
"vite": "^7.2.4",
|
|
40
|
-
"vitest": "^4.0.17"
|
|
41
|
+
"vitest": "^4.0.17",
|
|
42
|
+
"@playwright/test": "^1.49.0",
|
|
43
|
+
"serve": "^14.2.5"
|
|
41
44
|
}
|
|
42
45
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineConfig, devices } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
const E2E_PORT = 5175;
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
testDir: './e2e',
|
|
7
|
+
fullyParallel: true,
|
|
8
|
+
forbidOnly: !!process.env.CI,
|
|
9
|
+
retries: process.env.CI ? 2 : 0,
|
|
10
|
+
workers: process.env.CI ? 1 : undefined,
|
|
11
|
+
reporter: 'html',
|
|
12
|
+
use: {
|
|
13
|
+
baseURL: `http://localhost:${E2E_PORT}`,
|
|
14
|
+
trace: 'on-first-retry',
|
|
15
|
+
},
|
|
16
|
+
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
|
|
17
|
+
webServer: {
|
|
18
|
+
// Serve built dist/ with static server so e2e works in CI without SF org (vite preview runs plugin and can fail)
|
|
19
|
+
command: `npx serve dist -l ${E2E_PORT}`,
|
|
20
|
+
url: `http://localhost:${E2E_PORT}`,
|
|
21
|
+
reuseExistingServer: !process.env.CI,
|
|
22
|
+
timeout: process.env.CI ? 120_000 : 60_000,
|
|
23
|
+
},
|
|
24
|
+
});
|
package/src/force-app/main/default/webapplications/base-react-app/scripts/rewrite-e2e-assets.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prepares dist/ for e2e: root-relative asset paths + SPA fallback for serve.
|
|
3
|
+
*/
|
|
4
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { join, dirname } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const distDir = join(__dirname, '..', 'dist');
|
|
10
|
+
|
|
11
|
+
// Rewrite index.html so asset paths are root-relative (/assets/...)
|
|
12
|
+
const indexPath = join(distDir, 'index.html');
|
|
13
|
+
let html = readFileSync(indexPath, 'utf8');
|
|
14
|
+
html = html.replace(/(src|href)="[^"]*\/assets\//g, '$1="/assets/');
|
|
15
|
+
writeFileSync(indexPath, html);
|
|
16
|
+
|
|
17
|
+
// SPA fallback so /about, /non-existent-route etc. serve index.html
|
|
18
|
+
writeFileSync(
|
|
19
|
+
join(distDir, 'serve.json'),
|
|
20
|
+
JSON.stringify({
|
|
21
|
+
rewrites: [{ source: '**', destination: '/index.html' }],
|
|
22
|
+
})
|
|
23
|
+
);
|