Level / level-js

An abstract-leveldown compliant store on top of IndexedDB.
MIT License
542 stars 44 forks source link

Vite compatibility? #215

Closed KonradHoeffner closed 2 years ago

KonradHoeffner commented 2 years ago

Can level-js be used with Vite? If yes, how? I tried npm install level-js and import leveljs from "level-js"; but npm run dev reports error: Do not know how to load path: level-js.

xesrevinu commented 2 years ago

Yes, you can use level-js in Vite

Install

npm install levelup level-js

Put it in front of the code,

import { Buffer } from 'buffer';

// @ts-ignore
window.global = window;
// @ts-ignore
window.Buffer = Buffer;

add plugins in vite.config.js

import nodePolyfills from 'rollup-plugin-polyfill-node';

{
  plugins: [nodePolyfills()]
}

image

image