mirror of
https://github.com/expo/dev-plugins.git
synced 2026-11-15 03:38:09 -10:00
# Why add a proof-of-concept of using vanilla-js to build a plugin # How a plugin to show console logs using vanilla-js - vanilla-js / css / html - single file app-adapter js file - uses esbuild to bundle script.js + expo/devtools -> script-bundle.js
39 lines
993 B
JavaScript
Executable File
39 lines
993 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
const spawnAsync = require('@expo/spawn-async');
|
|
const path = require('path');
|
|
const rimraf = require('rimraf');
|
|
|
|
const ROOT = path.resolve(__dirname, '..');
|
|
|
|
async function runAsync() {
|
|
const args = process.argv.slice(2);
|
|
if (args.length === 0) {
|
|
console.log(`Usage: ${path.basename(process.argv[1])} package [package2...]`);
|
|
process.exit(1);
|
|
}
|
|
|
|
const packageNames = args;
|
|
for (const packageName of packageNames) {
|
|
await buildAsync(packageName);
|
|
}
|
|
}
|
|
|
|
async function buildAsync(packageName) {
|
|
console.log(`⚙️ Building web assets for ${packageName}`);
|
|
const packageRoot = path.join(ROOT, 'packages', packageName);
|
|
await rimraf.rimraf(path.join(packageRoot, 'dist'));
|
|
await spawnAsync('npx', ['expo', 'export', '-p', 'web', '--output-dir', '../dist'], {
|
|
cwd: path.join(packageRoot, 'webui'),
|
|
});
|
|
}
|
|
|
|
(async () => {
|
|
try {
|
|
await runAsync();
|
|
} catch (e) {
|
|
console.error('Uncaught Error', e);
|
|
process.exit(1);
|
|
}
|
|
})();
|