Skip to content

Commit

Permalink
feat(nx-dev): add watch to automatically sync docs to nx-dev when dev…
Browse files Browse the repository at this point in the history
…eloping locally
  • Loading branch information
juristr authored and vsavkin committed May 19, 2023
1 parent 7ab303f commit 3472897
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
11 changes: 11 additions & 0 deletions nx-dev/nx-dev/copy-docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { copySync } = require('fs-extra');
const path = require('path');

/**
* Copies the documentation into the proper Next.js public folder
*/
copySync(
path.resolve(path.join(__dirname, '../../docs')),
path.resolve(path.join(__dirname, 'public/documentation')),
{ overwrite: true }
);
11 changes: 0 additions & 11 deletions nx-dev/nx-dev/next.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
// nx-ignore-next-line
const { withNx } = require('@nx/next/plugins/with-nx');
const { copySync } = require('fs-extra');
const path = require('path');
const redirectRules = require('./redirect-rules.config');

/**
* TODO@ben: Use watch method instead.
*/
copySync(
path.resolve(__dirname + '/../../docs'),
path.resolve(__dirname + '/public/documentation'),
{ overwrite: true }
);

module.exports = withNx({
// For both client and server
env: {
Expand Down
20 changes: 20 additions & 0 deletions nx-dev/nx-dev/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
},
"build-base": {
"executor": "@nx/next:build",
"dependsOn": ["copy-docs"],
"outputs": ["{options.outputPath}"],
"options": {
"root": "nx-dev/nx-dev",
Expand All @@ -56,8 +57,27 @@
"production": {}
}
},
"copy-docs": {
"inputs": ["{workspaceRoot}/docs/**/*"],
"outputs": ["{projectRoot}/public/documentation"],
"command": "node ./copy-docs.js",
"options": {
"cwd": "nx-dev/nx-dev"
}
},
"serve-docs": {
"executor": "nx:run-commands",
"options": {
"commands": [
"nx watch --projects=docs -- nx run nx-dev:copy-docs",
"nx run nx-dev:serve"
],
"parallel": true
}
},
"serve": {
"executor": "@nx/next:server",
"dependsOn": ["copy-docs"],
"options": {
"buildTarget": "nx-dev:build-base",
"dev": true
Expand Down
3 changes: 2 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"test",
"test-native",
"sitemap",
"build-storybook"
"build-storybook",
"copy-docs"
],
"cacheDirectory": "/tmp/nx-cache",
"parallel": 1,
Expand Down

1 comment on commit 3472897

@vercel
Copy link

@vercel vercel bot commented on 3472897 May 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx.dev
nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app

Please sign in to comment.