42 lines
1.2 KiB
JavaScript
Raw Normal View History

const path = require('path');
const mkdirp = require('mkdirp');
const fs = require('fs-extra');
2020-12-28 22:42:58 -05:00
const Parcel = require('parcel-bundler');
const extractSVGs = require('./extract-svgHtml');
const destSVGPath = path.resolve(__dirname, '..', 'optimizedSVGs');
const distPath = path.resolve(__dirname, '..', 'dist');
const srcPath = path.resolve(__dirname, '..', 'src');
mkdirp(distPath).then(createIconsCache).then(src);
// copy src files
function src() {
2020-12-28 22:42:58 -05:00
const entryFile = path.resolve(srcPath, 'main.js');
const parcelOptions = {
watch: false,
minify: true,
};
const bundler = new Parcel(entryFile, parcelOptions);
2020-12-28 22:42:58 -05:00
const bundleMainScript = bundler.bundle();
const copyManifest = fs.copy(
path.resolve(srcPath, 'manifest.json'),
path.resolve(distPath, 'manifest.json')
);
2020-12-28 22:42:58 -05:00
2020-12-19 17:34:52 -05:00
const copyExtensionLogos = fs.copy(path.resolve(srcPath, 'extensionIcons'), distPath);
2020-12-28 22:42:58 -05:00
return Promise.all([copyManifest, copyExtensionLogos, bundleMainScript]);
}
function createIconsCache() {
return new Promise((resolve, reject) => {
fs.copy(path.resolve(srcPath, 'customIcons'), destSVGPath)
.then(() => extractSVGs())
.then(resolve)
.catch(reject);
});
}