A collection of builders and extensions for the https://nx.dev monorepo tooling.
OTHER License
Apployees-Nx is a collection of builders and extensions for the Nx monorepo tooling.
Here's a complete list of builders and tools for NX:
Note that this repository is itself an Nx repository. That is, we bootstrapped the first builder using Nx's original Node Builder, and used our Enhanced Node Builder to build the rest of the builders and tooling in Apployees-Nx.
See README.md for level-task-runner.
@apployees-nx/webserver
The Webserver builder and schematic is a Create-React-App-inspired Universal webserver. It is capable of:
Bundling your express server.
Bundling your client.
Server-side rendering on the client.
Generating a package.json file for you just like @apployees-nx/node below.
To use with a new project, start with the application schematic nx g @apployees-nx/webserver:app myApp
.
The schematic used when running nx g @apployees-nx/webserver:app myApp
will add a few scripts to your package.json:
yarn dev-myApp
for development. Nx will watch all affected files of myApp and automatically compile and restart myApp.
yarn test-myApp
runs all the Jest unit tests for myApp.
yarn lint-myApp
runs the linter on myApp.
yarn build-myApp
builds myApp for production.
yarn build-dev-myApp
builds myApp for development, watching for changes (this is the target that yarn dev-myApp
waits for before running the compiled output).
To use with an existing project, create a new project first using the above command and change the locations of files in angular/workspace.json to point to your existing project.
The Webserver builder is bootstrapped with apployees-nx/node
builder. You will first need to follow the bootstrapping instructions below from apployees-nx/node
then follow these instructions.
Here are the steps for developing @apployees-nx/webserver
itself:
Run yarn dev-webserver
.
Go to the dist folder and run yarn link.
cd dist/apps/webserver
yarn link
Go to the root directory and link webserver.
cd ../../..
yarn link "@apployees-nx/webserver"
To build before publishing webserver, simply run yarn build-webserver
.
You can now also build the rest of the apps with @apployees-nx/webserver
if they require it, or the use the same process to bootstrap another builder if it requires it.
@apployees-nx/webserver
in the examples directory you can play around with. Check out the package.json scripts for how to develop, run, and test them.@apployees-nx/node
Similar to the Nx Node Builder, with the following additions:
Options:
main
entry-point code, it also supports otherEntries
. Each of the otherEntries will become a separate, individually invokeable entry point (i.e., you will be able to do node myOtherEntryPoint.js
).externalLibraries
that controls which node_modules should or should not be bundled, you can also define externalLibraries
, which indicates which libraries within the mono-repo should or should not be bundled.Output:
externalDependencies
that you specified and output in to the dist folder.To use with a new project, start with the application schematic nx g @apployees-nx/node:app myApp
.
The schematic used when running nx g @apployees-nx/node:app myApp
will add a develop option and a few scripts to your package.json:
yarn dev-myApp
for development. Nx will watch all affected files of myApp and automatically compile and restart myApp.
yarn test-myApp
runs all the Jest unit tests for myApp.
yarn lint-myApp
runs the linter on myApp.
yarn build-myApp
builds myApp for production.
yarn build-dev-myApp
builds myApp for development, watching for changes (this is the target that yarn dev-myApp
waits for before running the compiled output).
To use with an existing project, simply open up your angular.json or workspace.json and replace @nrwl/node
with @apployees-nx/node
.
It is recommended that you create a dummy new project using nx g @apployees-nx/node:app myApp
just to see what things it adds to workspace.json/angular.json and package.json.
The Enhanced Node Builder is bootstrapped with Nx's default out-of-the-box Node Builder.
Here are the steps for developing @apployees-nx/node itself:
node
project:
node:architect:build:builder
field to the value @nrwl/node:build
instead of @apployees-nx/node:build
.node:architect:build:options:main
field to the value apps/node/src/builders/build/build.impl.ts
.node:architect:build:assets
to only have one entry: apps/node/src
.node:architect:build:options:otherEntries
exists. This will be ignored by @nrwl/node:build
, but will be used by @apployees-nx/node:build
later on. So keep this entry.apps/node/src/builders.json
and change:
builders:build:implementation
to be "./main"
.nx build node
.package.json
file from apps/node
to dist/apps/node
.cd dist/apps/node
yarn link
cd ../../..
) and run yarn link "@apployees-nx/node"
.@apployees-nx/node:build
for the node:architect:build:builder
field.apps/node/src/main.ts
for the node:architect:build:options:main
field.node:architect:build:assets
field should be just as before.apps/node/src/builders.json
and revert your changes.
builders:build:implementation
should be "./builder-build"
.nx build node
.
@apployees-nx/node
using an @nrwl/node
-builder-compiled version of @apployees-nx/node
at this point.@apployees-nx/node
package.@apployees-nx/node
, run yarn dev-node
. It will watch for changes and re-compile. Since it is already yarn-linked, you do not need to do anything else.@apployees-nx/node
, run yarn build-node
.@apployees-nx/node
if they require it, or the use the same process to bootstrap another builder if it requires it.
@apployees-nx/node
in the examples directory you can play around with. Check out the package.json scripts for how to develop, run, and test them.Note that an alternative to the above bootstrapping would have been to use the published version of @apployees-nx/node
instead of @nrwl/node
. That might actually be easier than above...but I wrote the above steps when I didn't even have a published builder initially.