bukopin-redemption-client-r.../scripts/link-assets.js
Hasta Ragil Saputra 3ee2588d4e fix: build time
2019-01-29 11:58:10 +07:00

40 lines
989 B
JavaScript

const symlink = require('symlink-or-copy').sync;
const path = require('path');
const fs = require('fs-extra-promise');
module.exports = () => {
const destPath = path.normalize(`${__dirname}/../dist`);
const assetPath = path.normalize(`${__dirname}/../dist/assets`);
fs.ensureDirSync(destPath);
fs.removeSync(path.normalize(assetPath));
const alreadyExist = fs.existsSync(assetPath);
if (!alreadyExist) {
const srcPath = path.normalize(`${__dirname}/../assets`);
symlink(srcPath, assetPath);
}
const destPath2 = path.normalize(`${__dirname}/../public`);
const assetPath2 = path.normalize(`${__dirname}/../public/assets`);
fs.ensureDirSync(destPath2);
fs.removeSync(path.normalize(assetPath2));
const alreadyExist2 = fs.existsSync(assetPath2);
if (!alreadyExist2) {
const srcPath = path.normalize(`${__dirname}/../assets`);
symlink(srcPath, assetPath2);
}
};
if (require.main === module) {
module.exports();
console.log('done');
}