2021-05-03 19:29:22 +02:00
|
|
|
import fs from "fs";
|
2021-05-27 15:26:19 +02:00
|
|
|
import path from "path";
|
|
|
|
import {copyRecursively} from "./_functions.js";
|
2021-04-23 18:19:05 +02:00
|
|
|
|
2021-04-27 15:44:20 +02:00
|
|
|
// These folders must exist for nodemon not to loop indefinitely.
|
2021-04-23 18:19:05 +02:00
|
|
|
[
|
|
|
|
'public',
|
2021-05-27 15:26:19 +02:00
|
|
|
'dist',
|
|
|
|
'intermediates',
|
|
|
|
'intermediates/assets',
|
2021-04-23 18:19:05 +02:00
|
|
|
].forEach(dir => {
|
|
|
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir);
|
|
|
|
});
|
2021-05-27 15:26:19 +02:00
|
|
|
|
|
|
|
// Symlink to build/common
|
|
|
|
const symlink = path.resolve('intermediates/common');
|
|
|
|
if (!fs.existsSync(symlink)) {
|
|
|
|
fs.symlinkSync(path.resolve('dist/common'), symlink);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy all source files
|
|
|
|
fs.readdirSync('src').forEach(file => {
|
|
|
|
copyRecursively(path.join('src', file), 'dist');
|
|
|
|
});
|