-
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(webpack): add plugin to automatically configure build and serve …
…targets for projects
- Loading branch information
Showing
62 changed files
with
1,659 additions
and
644 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { | ||
cleanupProject, | ||
newProject, | ||
runCLI, | ||
runE2ETests, | ||
uniq, | ||
} from '@nx/e2e/utils'; | ||
|
||
describe('Webpack Plugin (PCv3)', () => { | ||
let originalPcv3: string | undefined; | ||
beforeAll(() => { | ||
originalPcv3 = process.env.NX_PCV3; | ||
process.env.NX_PCV3 = 'true'; | ||
newProject(); | ||
}); | ||
|
||
afterAll(() => { | ||
process.env.NX_PCV3 = originalPcv3; | ||
cleanupProject(); | ||
}); | ||
|
||
it('should generate, build, and serve React applications', () => { | ||
const appName = uniq('app'); | ||
runCLI( | ||
`generate @nx/react:app ${appName} --bundler webpack --e2eTestRunner=cypress --no-interactive` | ||
); | ||
|
||
expect(() => runCLI(`build ${appName}`)).not.toThrow(); | ||
|
||
if (runE2ETests()) { | ||
runCLI(`e2e ${appName}-e2e --watch=false --verbose`); | ||
} | ||
}, 500_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
40 changes: 40 additions & 0 deletions
40
packages/node/src/generators/application/application.pcv3.spec.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
readNxJson, | ||
readProjectConfiguration, | ||
Tree, | ||
updateNxJson, | ||
} from '@nx/devkit'; | ||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; | ||
|
||
// nx-ignore-next-line | ||
import { applicationGenerator } from './application'; | ||
|
||
describe('node app generator (PCv3)', () => { | ||
let tree: Tree; | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace(); | ||
const nxJson = readNxJson(tree); | ||
nxJson.plugins ??= []; | ||
nxJson.plugins.push('@nx/webpack/plugin'); | ||
updateNxJson(tree, nxJson); | ||
}); | ||
|
||
it('should skip the build target and setup webpack config', async () => { | ||
await applicationGenerator(tree, { | ||
name: 'my-node-app', | ||
bundler: 'webpack', | ||
projectNameAndRootFormat: 'as-provided', | ||
}); | ||
const project = readProjectConfiguration(tree, 'my-node-app'); | ||
expect(project.root).toEqual('my-node-app'); | ||
expect(project.targets.build).toBeUndefined(); | ||
|
||
const webpackConfig = tree.read('my-node-app/webpack.config.js', 'utf-8'); | ||
expect(webpackConfig).toContain(`new NxWebpackPlugin`); | ||
expect(webpackConfig).toContain(`target: 'node'`); | ||
expect(webpackConfig).toContain(`'../dist/my-node-app'`); | ||
expect(webpackConfig).toContain(`main: './src/main.ts'`); | ||
expect(webpackConfig).toContain(`tsConfig: './tsconfig.app.json'`); | ||
}); | ||
}); |
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.