-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathcopy-assets.cjs
More file actions
31 lines (27 loc) · 779 Bytes
/
copy-assets.cjs
File metadata and controls
31 lines (27 loc) · 779 Bytes
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
const fs = require("fs");
const path = require("path");
const publicPath = path.resolve(__dirname, "./public");
const assets = [
{
from: "./website/public/",
to: "./",
},
{
from: "./playground/public/",
to: "./playground/",
},
];
// Clean prev public folder
console.log(`Clean public folder '${publicPath}'`);
if (fs.existsSync(publicPath)) {
fs.rmSync(publicPath, {recursive: true});
}
fs.mkdirSync(publicPath);
// Copy assets
console.log("Copying assets...");
assets.forEach(item => {
const sourcePath = path.resolve(__dirname, item.from);
const destPath = path.resolve(publicPath, item.to);
console.log(`Copying '${sourcePath}' => '${destPath}'`);
fs.cpSync(sourcePath, destPath, {recursive: true});
});