-
Notifications
You must be signed in to change notification settings - Fork 1.5k
build(desktop): integrate nx #16860
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
base: main
Are you sure you want to change the base?
build(desktop): integrate nx #16860
Conversation
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16860 +/- ##
==========================================
- Coverage 38.94% 38.93% -0.01%
==========================================
Files 3437 3437
Lines 97511 97511
Branches 14667 14667
==========================================
- Hits 37977 37970 -7
- Misses 57874 57881 +7
Partials 1660 1660 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9fcb044
to
0d5f1b7
Compare
/* eslint-disable @typescript-eslint/no-require-imports */ | ||
const path = require("path"); | ||
|
||
const concurrently = require("concurrently"); | ||
|
||
const rimraf = require("rimraf"); | ||
|
||
const args = process.argv.splice(2); | ||
|
||
const outputPath = path.resolve(__dirname, "../../../dist/apps/desktop"); | ||
rimraf.sync(outputPath); | ||
require("fs").mkdirSync(outputPath, { recursive: true }); | ||
|
||
concurrently( | ||
[ | ||
{ | ||
name: "Main", | ||
command: `cross-env NODE_ENV=development OUTPUT_PATH=${outputPath} webpack --config webpack.config.js --config-name main --watch`, | ||
prefixColor: "yellow", | ||
}, | ||
{ | ||
name: "Prel", | ||
command: `cross-env NODE_ENV=development OUTPUT_PATH=${outputPath} webpack --config webpack.config.js --config-name preload --watch`, | ||
prefixColor: "magenta", | ||
}, | ||
{ | ||
name: "Rend", | ||
command: `cross-env NODE_ENV=development OUTPUT_PATH=${outputPath} webpack --config webpack.config.js --config-name renderer --watch`, | ||
prefixColor: "cyan", | ||
}, | ||
{ | ||
name: "Elec", | ||
command: `npx wait-on ${outputPath}/main.js ${outputPath}/index.html && npx electron --no-sandbox --inspect=5858 ${args.join( | ||
" ", | ||
)} ${outputPath} --watch`, | ||
prefixColor: "green", | ||
}, | ||
], | ||
{ | ||
prefix: "name", | ||
outputStream: process.stdout, | ||
killOthers: ["success", "failure"], | ||
}, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole thing emulates start.js
that is used for serving right now. The only real difference is that it cuts npm
out of the equation - commands from package.json are in here instead.
0d5f1b7
to
e2aff37
Compare
e2aff37
to
28f1fe9
Compare
|
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-24802
📔 Objective
Enable Nx builds in the desktop app. For example:
Most complexity here is that we need to support the pre-nx build pipelines for a while, so we have to juggle both configurations. The recent refactor of our webpack config to a webpack config factory was pretty helpful here. I added some optional parameters that come from Nx in Nx builds. Most lines are just changes from relative paths to absolute paths to account for the fact that npm and nx have different working directories.
Once we update CI to use Nx builds exclusively, and the Nx builds have had time to get battle tested, we'll remove the old npm builds and this configuration will get much simpler.
Otherwise, this is a fairly straightforward port of the build commands from desktops's package.json into a functioning project.json. It uses the standard executors and follows Nx conventions for this kind of build without much else that is special.
📸 Screenshots
running

npx nx serve desktop
running

npx nx build desktop
running

npx nx build-native desktop
running

npx nx test desktop
andnpx nx lint desktop
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes