-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
52 lines (45 loc) Β· 1.59 KB
/
deploy.js
File metadata and controls
52 lines (45 loc) Β· 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { publish } from 'gh-pages';
import { execSync } from 'child_process';
import { copyFileSync } from 'fs';
console.log('π Starting deployment process...\n');
// Step 1: Build the project
console.log('π¦ Building project...');
try {
execSync('npm run build', { stdio: 'inherit' });
console.log('β
Build completed successfully\n');
} catch (error) {
console.error('β Build failed:', error.message);
process.exit(1);
}
// Step 2: Copy additional files for SPA
console.log('π Preparing deployment files...');
try {
// SPA GitHub Pages support: https://github.com/rafrex/spa-github-pages
copyFileSync('./app/404.html', './dist/404.html');
console.log(' β Copied 404.html for SPA routing');
console.log('');
} catch (error) {
console.error('β File preparation failed:', error.message);
process.exit(1);
}
// Step 3: Publish to GitHub Pages
const publishOptions = {
branch: 'gh-pages',
dotfiles: false,
add: false, // Replace all contents in gh-pages branch
cname: 'recipema.appletreelabs.com', // Custom domain
message: `Deploy: ${new Date().toISOString()}`
};
console.log('π Publishing to GitHub Pages...');
console.log(` Branch: ${publishOptions.branch}`);
console.log(` Custom domain: ${publishOptions.cname}`);
console.log(` Message: ${publishOptions.message}\n`);
publish('./dist', publishOptions, (err) => {
if (err) {
console.error('β Deployment failed:', err.message);
process.exit(1);
} else {
console.log('β
Deployment to GitHub Pages successful!');
console.log('π Site is live at: https://recipema.appletreelabs.com\n');
}
});