0.1.0 • Published 4 years ago

webpack-sandbox-external-plugin v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Webpack Sandbox External Plugin

This webpack plugin treats modules as externals in a way that doesn't cause errors when their required in an Electron sandbox.

It is heavily based on webpack's internal Webpack plugin.

Instead of outputting code like:

module.exports = require('keytar');

It outputs code like this for externals:

if (!process.sandboxed) module.exports = require('keytar');

Install

yarn add -D webpack-sandbox-external-plugin

Usage

Add the plugin to your webpack config. For example:

const SandboxExternalPlugin = require('webpack-sandbox-external-plugin');

module.exports = {
  plugins: [
    new SanboxSafeExternalsPlugin(
      'commonjs', // output type
      ['sqlite3', 'keytar'], // modules to externalize
    ),
  ],
};

:warning: Only works for commonjs outputs, currently.

0.1.0

4 years ago