Initial commit
This commit is contained in:
11
scripts/build-parcel.js
Normal file
11
scripts/build-parcel.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const spawn = require("cross-spawn");
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra-promise');
|
||||
|
||||
fs.removeSync(path.normalize(`${__dirname}/../.cache`));
|
||||
fs.removeSync(path.normalize(`${__dirname}/../dist`));
|
||||
|
||||
require("./link-assets")();
|
||||
// Spawn NPM synchronously
|
||||
const result = spawn.sync('parcel', 'build public/index.parcel.html --log-level 4 --out-file index.html --detailed-report --no-source-maps'.split(" "), { stdio: 'inherit' });
|
||||
|
||||
7
scripts/dev-parcel.js
Normal file
7
scripts/dev-parcel.js
Normal file
@@ -0,0 +1,7 @@
|
||||
const spawn = require("cross-spawn");
|
||||
|
||||
require("./link-assets")();
|
||||
|
||||
// Spawn NPM synchronously
|
||||
const result = spawn.sync('parcel', 'public/index.parcel.html --log-level 4 --out-file index.html --global $'.split(" "), { stdio: 'inherit' });
|
||||
|
||||
33
scripts/link-assets.js
Normal file
33
scripts/link-assets.js
Normal file
@@ -0,0 +1,33 @@
|
||||
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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user