major: flatten the project
This commit is contained in:
77
internal/parcel.js
Normal file
77
internal/parcel.js
Normal file
@ -0,0 +1,77 @@
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const fse = require('fs-extra');
|
||||
const Bundler = require('parcel-bundler');
|
||||
|
||||
const options = {
|
||||
outDir: './dist',
|
||||
outFile: 'index.html',
|
||||
publicUrl: '/',
|
||||
watch: process.env.NODE_ENV !== 'production',
|
||||
cache: true,
|
||||
cacheDir: '.cache',
|
||||
contentHash: false,
|
||||
minify: process.env.NODE_ENV === 'production',
|
||||
scopeHoist: false,
|
||||
target: 'browser',
|
||||
bundleNodeModules: false,
|
||||
https: true,
|
||||
logLevel: 3,
|
||||
hmr: true,
|
||||
hmrPort: 1235,
|
||||
sourceMaps: true,
|
||||
hmrHostname: '',
|
||||
detailedReport: false,
|
||||
autoInstall: true
|
||||
};
|
||||
|
||||
(async function() {
|
||||
if(!fs.existsSync("config.json")) throw "[Error] (Mandatory) Missing config.json file";
|
||||
|
||||
let config = JSON.parse(fs.readFileSync('config.json'));
|
||||
|
||||
if(!config.clientName) throw "[Error] (Mandatory) Missing clientName on config.json";
|
||||
if(!config.clientLogo) throw "[Error] (Mandatory) Missing clientLogo on config.json";
|
||||
|
||||
let manifest = {
|
||||
"lang": "fr",
|
||||
"dir": "ltr",
|
||||
"name": config.clientName,
|
||||
"description": `Hubl of ${config.clientName}`,
|
||||
"short_name": config.clientName,
|
||||
"icons": [{
|
||||
"src": config.clientLogo,
|
||||
"purpose": "any"
|
||||
}, {
|
||||
"src": "/images/hubl-icon-192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
}, {
|
||||
"src": "/images/hubl-icon-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"orientation": "portrait",
|
||||
"background_color": "#fff",
|
||||
'theme_color': "white"
|
||||
}
|
||||
|
||||
await fse.writeJSON('./src/manifest.webmanifest', manifest)
|
||||
console.log(`Created manifest for ${config.clientName}`);
|
||||
|
||||
await fse.copy("./src/locales", "./dist/locales")
|
||||
console.log(`Copied locales to dist folder`);
|
||||
|
||||
await fse.copy("./src/components", "./dist/components")
|
||||
console.log(`Copied components to dist folder`);
|
||||
|
||||
const bundler = new Bundler('./src/index.pug', options);
|
||||
bundler.addAssetType('html', require.resolve('./assets.js'));
|
||||
if(process.env.NODE_ENV !== 'production') {
|
||||
await bundler.serve();
|
||||
} else {
|
||||
await bundler.bundle();
|
||||
}
|
||||
})();
|
Reference in New Issue
Block a user