-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyncStaticAssets.js
More file actions
40 lines (33 loc) · 1.24 KB
/
syncStaticAssets.js
File metadata and controls
40 lines (33 loc) · 1.24 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
// Copy files from the static-assets directory to the dist directory using fs
// This script is executed by the build process
import { RESET_STYLES } from '@nordcraft/core/dist/styling/theme.const'
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const resolvePath = (...segments) => path.resolve(__dirname, ...segments)
try {
const staticDir = resolvePath('../assets/_static')
const distDir = resolvePath('../dist')
fs.mkdirSync(staticDir, { recursive: true })
fs.mkdirSync(distDir, { recursive: true })
const filesToCopy = [
'page.main.esm.js',
'page.main.esm.js.map',
'custom-element.main.esm.js',
]
filesToCopy.forEach((file) => {
const source = resolvePath('../node_modules/@nordcraft/runtime/dist', file)
const destination = resolvePath('../assets/_static', file)
fs.copyFileSync(source, destination)
})
fs.writeFileSync(resolvePath('../assets/_static/reset.css'), RESET_STYLES)
fs.copyFileSync(
resolvePath('../__project__/project.json'),
resolvePath('../dist/project.json'),
)
} catch (error) {
console.error('Error during static assets sync:', error)
process.exit(1)
}