Demonstrates bundling
level
for browsers usingwebpack
.
See alsoLevel/browserify-starter
.
git clone https://github.com/Level/webpack-starter.git
cd webpack-starter
npm install
npm run build
Then open index.html
in a browser of choice. You're now ready to use your level
database, backed by IndexedDB!
In order to reduce bundle size, the webpack configuration at webpack.config.js
excludes the buffer
polyfill. To store binary data, either change the webpack configuration, or use Uint8Array instead of Buffer. For example:
import { Level } from 'level'
const db = new Level('webpack-starter', {
keyEncoding: 'view'
})
await db.put(new Uint8Array([1, 2]), 'example')
const example = await db.get(new Uint8Array([1, 2]))
Level/webpack-starter
is an OPEN Open Source Project. This means that:
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
See the Contribution Guide for more details.
Support us with a monthly donation on Open Collective and help us continue our work.