Skip to content

Instantly share code, notes, and snippets.

@nnooney
Created December 31, 2016 01:45
Show Gist options
  • Save nnooney/816ad3f483aa7b85e7dcd64896de0cac to your computer and use it in GitHub Desktop.
Save nnooney/816ad3f483aa7b85e7dcd64896de0cac to your computer and use it in GitHub Desktop.
NeDB & Electron & Rollup
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<script src="build.js"></script>
</body>
</html>
import Datastore from 'nedb';
const { app, BrowserWindow } = require('electron');
const path = require('path');
const url = require('url');
app.on('ready', () => {
win = new BrowserWindow({ width: 800, height: 600 });
win.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}));
win.webContents.openDevTools();
});
app.on('window-all-closed', () => {
app.quit();
});
{
"main": "main.js",
"dependencies": {
"electron": "^1.4.13",
"nedb": "^1.8.0",
"rollup": "^0.39.2",
"rollup-plugin-commonjs": "^7.0.0",
"rollup-plugin-node-builtins": "^2.0.0",
"rollup-plugin-node-globals": "^1.1.0",
"rollup-plugin-node-resolve": "^2.0.0"
}
}

Steps to reproduce error:

  1. install dependencies npm install
  2. build the project rollup -c
  3. start the Electron app electron .
import resolve from 'rollup-plugin-node-resolve';
import builtins from 'rollup-plugin-node-builtins';
import commonjs from 'rollup-plugin-commonjs';
export default {
moduleName: 'Demo',
entry: 'index.js',
dest: 'build.js',
format: 'iife',
plugins: [
builtins(),
resolve({
jsnext: true,
main: true,
browser: true,
}),
commonjs(),
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment