-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrollup.config.js
More file actions
76 lines (66 loc) · 1.98 KB
/
rollup.config.js
File metadata and controls
76 lines (66 loc) · 1.98 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// See: https://rollupjs.org/introduction/
import commonjs from '@rollup/plugin-commonjs'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import json from '@rollup/plugin-json'
import { copyFileSync, mkdirSync, readdirSync, statSync } from 'fs'
import { join, dirname } from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
// Plugin to copy views and public directories
function copyWebAssets() {
return {
name: 'copy-web-assets',
writeBundle() {
// Copy views directory
const srcViewsDir = join(__dirname, 'src/web/views')
const distViewsDir = join(__dirname, 'dist/views')
mkdirSync(distViewsDir, { recursive: true })
const viewFiles = readdirSync(srcViewsDir)
viewFiles.forEach((file) => {
copyFileSync(join(srcViewsDir, file), join(distViewsDir, file))
})
// Copy public directory
const srcPublicDir = join(__dirname, 'src/web/public')
const distPublicDir = join(__dirname, 'dist/public')
try {
mkdirSync(distPublicDir, { recursive: true })
const publicFiles = readdirSync(srcPublicDir)
publicFiles.forEach((file) => {
const srcPath = join(srcPublicDir, file)
const distPath = join(distPublicDir, file)
if (statSync(srcPath).isFile()) {
copyFileSync(srcPath, distPath)
}
})
} catch (e) {
// Public directory might not exist, that's ok
}
console.log('✅ Copied web assets to dist/')
}
}
}
const config = {
input: 'src/index.js',
output: {
file: 'dist/index.cjs',
format: 'cjs',
sourcemap: true
},
external: [
'@ngrok/ngrok',
'express',
'ejs'
//'@actions/core',
//'@actions/github',
//'@octokit/rest',
//'openai'
],
plugins: [
json(),
commonjs(),
nodeResolve({ preferBuiltins: true }),
copyWebAssets() // Copy the template files
]
}
export default config