'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: process.env.NODE_ENV !== 'production', cacheDir: '.cache', contentHash: false, minify: false, scopeHoist: false, target: 'browser', bundleNodeModules: false, https: true, logLevel: 3, hmr: false, hmrPort: 1235, sourceMaps: true, hmrHostname: '', detailedReport: false, autoInstall: true }; ((async function () { let configPath = process.env.CONFIG_PATH || 'config.json'; if (!fs.existsSync(configPath)) throw console.error(Error(`(Mandatory) Missing ${configPath} file`)); console.log(`Using ${configPath} config file`); let config = JSON.parse(fs.readFileSync(configPath)); let manifest = { "lang": "fr", "dir": "ltr", "name": config.client.name || "My Personal Orbit", "description": `Orbit of ${config.client.name || "My Personal Orbit"}`, "short_name": config.client.name || "My Personal Orbit", "icons": [{ "src": config.client.logo || '/images/logo.webp', "purpose": "any" }, { "src": "/images/orbit-icon-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "/images/orbit-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.client.name || "My Personal Orbit"}`); 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(process.env.PORT ? process.env.PORT : 1234); } else { await bundler.bundle(); } })()).catch((e) => { process.exitCode = 1; });