-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vue): init, app, component and lib generators
Co-Authored-By: Jack Hsu <[email protected]>
- Loading branch information
Showing
86 changed files
with
4,856 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
title: Overview of the Nx Vue Plugin | ||
description: The Nx Plugin for Vue contains generators for managing Vue applications and libraries within an Nx workspace. This page also explains how to configure Vue on your Nx workspace. | ||
--- | ||
|
||
The Nx plugin for [Vue](https://vuejs.org/). | ||
|
||
## Setting up a new Nx workspace with Vue | ||
|
||
You can create a new workspace that uses Vue with one of the following commands: | ||
|
||
- Generate a new monorepo with a Vue app set up with Vue | ||
|
||
```shell | ||
npx create-nx-workspace@latest --preset=vue | ||
``` | ||
|
||
## Add Vue to an existing workspace | ||
|
||
There are a number of ways to use Vue in your existing workspace. | ||
|
||
### Install the `@nx/vue` plugin | ||
|
||
{% tabs %} | ||
{% tab label="npm" %} | ||
|
||
```shell | ||
npm install -D @nx/vue | ||
``` | ||
|
||
{% /tab %} | ||
{% tab label="yarn" %} | ||
|
||
```shell | ||
yarn add -D @nx/vue | ||
``` | ||
|
||
{% /tab %} | ||
{% tab label="pnpm" %} | ||
|
||
```shell | ||
pnpm install -D @nx/vue | ||
``` | ||
|
||
{% /tab %} | ||
{% /tabs %} | ||
|
||
### Generate a new project using Vue | ||
|
||
To generate a Vue application, run the following: | ||
|
||
```bash | ||
nx g @nx/vue:app my-app | ||
``` | ||
|
||
To generate a Vue library, run the following: | ||
|
||
```bash | ||
nx g @nx/vue:lib my-lib | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { | ||
cleanupProject, | ||
killPorts, | ||
newProject, | ||
promisifiedTreeKill, | ||
runCLI, | ||
runCLIAsync, | ||
runCommandUntil, | ||
uniq, | ||
} from '@nx/e2e/utils'; | ||
|
||
const myApp = uniq('my-app'); | ||
const myLib = uniq('my-lib'); | ||
|
||
describe('Vue Plugin', () => { | ||
let proj: string; | ||
|
||
describe('Vite on React apps', () => { | ||
describe('successfully create and serve a vue app', () => { | ||
beforeEach(() => { | ||
proj = newProject({ | ||
unsetProjectNameAndRootFormat: false, | ||
}); | ||
runCLI(`generate @nx/vue:app ${myApp}`); | ||
runCLI(`generate @nx/vue:lib ${myLib} --bundler=vite`); | ||
}); | ||
afterEach(() => cleanupProject()); | ||
|
||
it('should serve application in dev mode', async () => { | ||
const p = await runCommandUntil(`run ${myApp}:serve`, (output) => { | ||
return output.includes('Local:'); | ||
}); | ||
try { | ||
await promisifiedTreeKill(p.pid, 'SIGKILL'); | ||
await killPorts(4200); | ||
} catch (e) { | ||
// ignore | ||
} | ||
}, 200_000); | ||
|
||
it('should test application', async () => { | ||
const result = await runCLIAsync(`test ${myApp}`); | ||
expect(result.combinedOutput).toContain( | ||
`Successfully ran target test for project ${myApp}` | ||
); | ||
}); | ||
|
||
it('should build application', async () => { | ||
const result = await runCLIAsync(`build ${myApp}`); | ||
expect(result.combinedOutput).toContain( | ||
`Successfully ran target build for project ${myApp}` | ||
); | ||
}); | ||
|
||
it('should build library', async () => { | ||
const result = await runCLIAsync(`build ${myLib}`); | ||
expect(result.combinedOutput).toContain( | ||
`Successfully ran target build for project ${myLib}` | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,7 @@ describe('app', () => { | |
'vitest/importMeta', | ||
'vite/client', | ||
'node', | ||
'vitest', | ||
]); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
packages/react/src/generators/application/lib/find-free-port.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,7 @@ describe('lib', () => { | |
'vitest/importMeta', | ||
'vite/client', | ||
'node', | ||
'vitest', | ||
]); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.