swaf/scripts/prepare-sources.js

28 lines
705 B
JavaScript
Raw Normal View History

const fs = require('fs');
const path = require('path');
2021-11-20 15:34:58 +01:00
const {copyRecursively} = require("./_functions");
2021-04-27 15:44:20 +02:00
// These folders must exist for nodemon not to loop indefinitely.
[
'public',
'dist',
'intermediates',
'intermediates/assets',
].forEach(dir => {
if (!fs.existsSync(dir)) fs.mkdirSync(dir);
});
// Symlink to build/common
const symlink = path.resolve('intermediates/common');
if (!fs.existsSync(symlink)) {
fs.symlinkSync(path.resolve('dist/common'), symlink);
}
2021-11-20 15:34:58 +01:00
// Copy assets
fs.readdirSync('src/assets').forEach(file => {
copyRecursively(path.join('src/assets', file), 'dist/assets');
});
// Copy package.json
fs.copyFileSync('package.json', 'dist/package.json');