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

refactor: rewrite tests to use webpack compiler, drop node 8 #360

Merged
merged 25 commits into from
Mar 5, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
only dont stub on main thread electron
  • Loading branch information
beeequeue committed Mar 4, 2021
commit d94ded6325fb348948da66d9ddf123d9e59bf5cc
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const interpolate = (env, vars) => {
return env
}

const isMainThreadElectron = (target) =>
target.startsWith('electron') && target.endsWith('main')

class Dotenv {
/**
* The dotenv-webpack plugin.
Expand Down Expand Up @@ -154,7 +157,7 @@ class Dotenv {
// https://github.com/mrsteele/dotenv-webpack/issues/240#issuecomment-710231534
// However, if someone targets Node or Electron `process.env` still exists, and should therefore be kept
// https://webpack.js.org/configuration/target
if (!target.startsWith('node') && !target.startsWith('electron')) {
if (!target.startsWith('node') && !isMainThreadElectron(target)) {
// Results in `"MISSING_ENV_VAR".NAME` which is valid JS
formatted['process.env'] = '"MISSING_ENV_VAR"'
beeequeue marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down