https://github.com/janeasystems/webpack-sandbox-external-plugin
Webpack plugin to treat a module as an external that's safe to run in an Electron sandbox.
https://github.com/janeasystems/webpack-sandbox-external-plugin
Last synced: about 2 months ago
JSON representation
Webpack plugin to treat a module as an external that's safe to run in an Electron sandbox.
- Host: GitHub
- URL: https://github.com/janeasystems/webpack-sandbox-external-plugin
- Owner: JaneaSystems
- License: other
- Created: 2020-08-04T17:33:22.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-04T19:23:30.000Z (almost 6 years ago)
- Last Synced: 2025-10-20T23:45:57.312Z (8 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```javascript
module.exports = require('keytar');
```
It outputs code like this for externals:
```javascript
if (!process.sandboxed) module.exports = require('keytar');
```
## Install
```sh
yarn add -D webpack-sandbox-external-plugin
```
## Usage
Add the plugin to your `webpack` config. For example:
```javascript
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.