Lean & Zero-dep
JSON parsing and native file watching packed into less than 8 KB gzipped. No transitive dependencies.
The only zero-dep config loader that does discovery, hierarchical merge, live-reload, and plugins.
Edit the base or local configuration files to see hierarchical merging and live events in real-time.
pnpm add @oclio/morselnpm install @oclio/morselyarn add @oclio/morselimport { defineConfig, loadConfig } from '@oclio/morsel';
const myApp = defineConfig({
name: 'myapp',
defaults: { port: 3000, host: 'localhost' },
});
const { config } = await loadConfig(myApp);
console.log(config.port); // 3000, or overridden by ./myapp.config.jsonimport { defineConfig, watchConfig } from '@oclio/morsel';
const myApp = defineConfig({
name: 'myapp',
defaults: { port: 3000, host: 'localhost' },
});
const store = await watchConfig(myApp);
store.on('port', (next, prev) => {
console.log(`port: ${prev} → ${next}`);
});
// Edit ./myapp.config.json → the event fires automatically
store.stop();