Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix webpack issue when enable sandbox #246

Open
abbie982 opened this issue Nov 5, 2024 · 0 comments
Open

Fix webpack issue when enable sandbox #246

abbie982 opened this issue Nov 5, 2024 · 0 comments

Comments

@abbie982
Copy link
Contributor

abbie982 commented Nov 5, 2024

To enable the sandbox in browser webview of desktop app, we need to change the webpack config for preload.js in:/packages/injected/webpack.config.cjs as follow:

const nativeConfig = merge(commonConfig, {
  target: 'electron-preload',
  entry: {
    injectedDesktop: './src/injectedDesktop.ts',
  },
});

to the new one:

const nativeConfig = merge(commonConfig, {
  target: 'web',
  entry: {
    injectedDesktop: './src/injectedDesktop.ts',
  },
  externals: {
    electron: 'commonjs electron', // 将 Electron 标记为外部模块
  },
});

Otherwise, there will be a issue caused by import electron in preload.js, because of the limitation of sandbox such as limitation in require.

PR related to this is here:Change preload.js webpack config to support sandbox

PR related to app's sandbox config is here:Enable sandbox in browser's webview of desktop

#245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant