-
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(vite): nodes for build, serve, test, preview targets (#20086)
- Loading branch information
Showing
19 changed files
with
846 additions
and
116 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { cleanupProject, newProject, runCLI, uniq } from '@nx/e2e/utils'; | ||
|
||
const myApp = uniq('my-app'); | ||
|
||
describe('@nx/vite/plugin', () => { | ||
let proj: string; | ||
let originalEnv: string; | ||
|
||
beforeAll(() => { | ||
originalEnv = process.env.NX_PCV3; | ||
process.env.NX_PCV3 = 'true'; | ||
}); | ||
|
||
afterAll(() => { | ||
process.env.NODE_ENV = originalEnv; | ||
}); | ||
|
||
describe('build and test React Vite app', () => { | ||
beforeAll(() => { | ||
proj = newProject(); | ||
runCLI( | ||
`generate @nx/react:app ${myApp} --bundler=vite --unitTestRunner=vitest` | ||
); | ||
}); | ||
|
||
afterAll(() => cleanupProject()); | ||
|
||
it('should build application', () => { | ||
const result = runCLI(`build ${myApp}`); | ||
expect(result).toContain('Successfully ran target build'); | ||
}, 200_000); | ||
|
||
it('should test application', () => { | ||
const result = runCLI(`test ${myApp}`); | ||
expect(result).toContain('Successfully ran target test'); | ||
}, 200_000); | ||
}); | ||
|
||
describe('build and test Vue app', () => { | ||
beforeAll(() => { | ||
proj = newProject(); | ||
runCLI(`generate @nx/vue:app ${myApp} --unitTestRunner=vitest`); | ||
}); | ||
|
||
afterAll(() => { | ||
cleanupProject(); | ||
}); | ||
|
||
it('should build application', () => { | ||
const result = runCLI(`build ${myApp}`); | ||
expect(result).toContain('Successfully ran target build'); | ||
}, 200_000); | ||
|
||
it('should test application', () => { | ||
const result = runCLI(`test ${myApp}`); | ||
expect(result).toContain('Successfully ran target test'); | ||
}, 200_000); | ||
}); | ||
}); |
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,10 @@ | ||
import { readNxJson, Tree } from '@nx/devkit'; | ||
|
||
export function hasVitePlugin(tree: Tree) { | ||
const nxJson = readNxJson(tree); | ||
return !!nxJson.plugins?.some((p) => | ||
typeof p === 'string' | ||
? p === '@nx/vite/plugin' | ||
: p.plugin === '@nx/vite/plugin' | ||
); | ||
} |
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,5 @@ | ||
export { | ||
createNodes, | ||
VitePluginOptions, | ||
createDependencies, | ||
} from './src/plugins/plugin'; |
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
Oops, something went wrong.