Fixed cloudflare build.
Some checks failed
farmcontrol/farmcontrol-ui/pipeline/head There was a failure building this commit
Some checks failed
farmcontrol/farmcontrol-ui/pipeline/head There was a failure building this commit
This commit is contained in:
parent
075dfc6481
commit
96f1ab077c
4
Jenkinsfile
vendored
4
Jenkinsfile
vendored
@ -20,7 +20,7 @@ def deploy() {
|
|||||||
|
|
||||||
stage('Build (Ubuntu)') {
|
stage('Build (Ubuntu)') {
|
||||||
nodejs(nodeJSInstallationName: 'Node23') {
|
nodejs(nodeJSInstallationName: 'Node23') {
|
||||||
sh 'NODE_ENV=production pnpm build'
|
sh 'NODE_ENV=production pnpm build:cloudflare'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ def deploy() {
|
|||||||
nodejs(nodeJSInstallationName: 'Node23') {
|
nodejs(nodeJSInstallationName: 'Node23') {
|
||||||
// Deploy to Cloudflare Pages using wrangler
|
// Deploy to Cloudflare Pages using wrangler
|
||||||
withCredentials([string(credentialsId: 'cloudflare-api-token', variable: 'CLOUDFLARE_API_TOKEN')]) {
|
withCredentials([string(credentialsId: 'cloudflare-api-token', variable: 'CLOUDFLARE_API_TOKEN')]) {
|
||||||
sh 'pnpm wrangler pages deploy build'
|
sh 'pnpm wrangler pages deploy build --branch main'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,7 +72,8 @@
|
|||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"dev:electron": "concurrently \"cross-env NODE_ENV=development vite --no-open\" \"cross-env ELECTRON_START_URL=http://localhost:5780 cross-env NODE_ENV=development electron public/electron.js\"",
|
"dev:electron": "concurrently \"cross-env NODE_ENV=development vite --no-open\" \"cross-env ELECTRON_START_URL=http://localhost:5780 cross-env NODE_ENV=development electron public/electron.js\"",
|
||||||
"build:electron": "vite build && electron-builder",
|
"build:electron": "vite build && electron-builder",
|
||||||
"deploy": "vite build && wrangler pages deploy --branch main"
|
"build:cloudflare": "cross-env VITE_DEPLOY_TARGET=cloudflare vite build",
|
||||||
|
"deploy": "npm run build:cloudflare && wrangler pages deploy --branch main"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"extends": [
|
"extends": [
|
||||||
@ -142,6 +143,7 @@
|
|||||||
],
|
],
|
||||||
"mergeASARs": true,
|
"mergeASARs": true,
|
||||||
"x64ArchFiles": "**/node_modules/@esbuild/darwin-x64/**",
|
"x64ArchFiles": "**/node_modules/@esbuild/darwin-x64/**",
|
||||||
|
"singleArchFiles": "**/node_modules/@antv/**",
|
||||||
"extendInfo": {
|
"extendInfo": {
|
||||||
"CFBundleURLTypes": [
|
"CFBundleURLTypes": [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -10,8 +10,10 @@ import { visualizer } from 'rollup-plugin-visualizer'
|
|||||||
const __filename = fileURLToPath(import.meta.url)
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
const __dirname = path.dirname(__filename)
|
const __dirname = path.dirname(__filename)
|
||||||
|
|
||||||
|
const isCloudflare = process.env.VITE_DEPLOY_TARGET === 'cloudflare'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
base: './', // Required for Electron file:// protocol - absolute paths fail
|
base: isCloudflare ? '/' : './', // Cloudflare Pages needs absolute paths; Electron needs relative for file://
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
three: path.resolve(__dirname, 'node_modules/three')
|
three: path.resolve(__dirname, 'node_modules/three')
|
||||||
@ -20,7 +22,22 @@ export default defineConfig({
|
|||||||
optimizeDeps: {
|
optimizeDeps: {
|
||||||
include: ['@ant-design/icons']
|
include: ['@ant-design/icons']
|
||||||
},
|
},
|
||||||
plugins: [react(), svgo(), svgr(), eslintPlugin(), visualizer()],
|
plugins: [
|
||||||
|
react(),
|
||||||
|
svgo(),
|
||||||
|
svgr(),
|
||||||
|
eslintPlugin(),
|
||||||
|
visualizer(),
|
||||||
|
// Transform index.html paths to absolute when building for Cloudflare Pages
|
||||||
|
isCloudflare && {
|
||||||
|
name: 'cloudflare-html-paths',
|
||||||
|
transformIndexHtml(html) {
|
||||||
|
return html
|
||||||
|
.replace(/href="\.\//g, 'href="/')
|
||||||
|
.replace(/src="\.\//g, 'src="/')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
].filter(Boolean),
|
||||||
build: {
|
build: {
|
||||||
outDir: 'build',
|
outDir: 'build',
|
||||||
chunkSizeWarningLimit: 2000,
|
chunkSizeWarningLimit: 2000,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user