Skip to content

Commit

Permalink
feat: change output directory from "server" to "analog"
Browse files Browse the repository at this point in the history
made the changes so the vite-nitro-plugin.ts outputs to
an "analog" folder instead of "server" folder. added an integration
test for the blog-app that uses the build output from said
"analog" folder. Tried to do the same for the analog-app but ran
 into this issue with nx and cypress:
 nrwl/nx#10814.
 Waiting for guidance on that before making any other e2e changes.
 I think ideally we check this output as part of the e2e test
 for create analog as described in issue 201.

Closes #295
  • Loading branch information
goetzrobin committed Mar 20, 2023
1 parent 03c0776 commit c8cbf24
Show file tree
Hide file tree
Showing 18 changed files with 635 additions and 21 deletions.
4 changes: 3 additions & 1 deletion apps/analog-app-e2e-cypress/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const cypressJsonConfig = {
};
export default defineConfig({
e2e: {
...nxE2EPreset(__dirname),
...nxE2EPreset(__dirname, {
bundler: 'vite',
}),
...cypressJsonConfig,
},
});
2 changes: 1 addition & 1 deletion apps/analog-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"{options.outputPath}",
"dist/apps/analog-app/.nitro",
"dist/apps/analog-app/ssr",
"dist/apps/analog-app/server"
"dist/apps/analog-app/analog"
],
"options": {
"configFile": "apps/analog-app/vite.config.ts",
Expand Down
4 changes: 2 additions & 2 deletions apps/analog-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default defineConfig(({ mode }) => {
nitro: {
rootDir: 'apps/analog-app',
output: {
dir: '../../../dist/apps/analog-app/server',
publicDir: '../../../dist/apps/analog-app/server/public',
dir: '../../../dist/apps/analog-app/analog',
publicDir: '../../../dist/apps/analog-app/analog/public',
},
publicAssets: [{ dir: `../../../dist/apps/analog-app/client` }],
serverAssets: [
Expand Down
10 changes: 10 additions & 0 deletions apps/blog-app-e2e-cypress/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
}
]
}
21 changes: 21 additions & 0 deletions apps/blog-app-e2e-cypress/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { defineConfig } from 'cypress';
import { nxE2EPreset } from '@nrwl/cypress/plugins/cypress-preset';

const cypressJsonConfig = {
fileServerFolder: '.',
fixturesFolder: './src/fixtures',
video: true,
videosFolder: '../../dist/cypress/apps/blog-app-e2e-cypress/videos',
screenshotsFolder: '../../dist/cypress/apps/blog-app-e2e-cypress/screenshots',
chromeWebSecurity: false,
specPattern: 'src/e2e/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'src/support/e2e.ts',
};
export default defineConfig({
e2e: {
...nxE2EPreset(__dirname, {
bundler: 'vite',
}),
...cypressJsonConfig,
},
});
30 changes: 30 additions & 0 deletions apps/blog-app-e2e-cypress/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "blog-app-e2e-cypress",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/blog-app-e2e-cypress/src",
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "apps/blog-app-e2e-cypress/cypress.config.ts",
"devServerTarget": "blog-app:serve-nitro",
"testingType": "e2e"
},
"configurations": {
"watch": {
"watch": "true"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/blog-app-e2e-cypress/**/*.{js,ts}"]
}
}
},
"tags": [],
"implicitDependencies": ["blog-app"]
}
7 changes: 7 additions & 0 deletions apps/blog-app-e2e-cypress/src/e2e/app.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
describe('blog-app', () => {
beforeEach(() => cy.visit('/'));

it('should redirect us to /blog', () => {
cy.url().should('be.equal', `${Cypress.config('baseUrl')}/blog`);
});
});
1 change: 1 addition & 0 deletions apps/blog-app-e2e-cypress/src/fixtures/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions apps/blog-app-e2e-cypress/src/support/app.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// leaving this empty for now
33 changes: 33 additions & 0 deletions apps/blog-app-e2e-cypress/src/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************

// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// interface Chainable<Subject> {
// login(email: string, password: string): void;
// }
}
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => {
// console.log('Custom command example: Login', email, password);
// });
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
17 changes: 17 additions & 0 deletions apps/blog-app-e2e-cypress/src/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands';
10 changes: 10 additions & 0 deletions apps/blog-app-e2e-cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../dist/out-tsc",
"allowJs": true,
"types": ["cypress", "node"]
},
"include": ["src/**/*.ts", "src/**/*.js", "cypress.config.ts"]
}
11 changes: 10 additions & 1 deletion apps/blog-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"{options.outputPath}",
"dist/apps/blog-app/.nitro",
"dist/apps/blog-app/ssr",
"dist/apps/blog-app/server"
"dist/apps/blog-app/analog"
],
"options": {
"configFile": "apps/blog-app/vite.config.ts",
Expand Down Expand Up @@ -44,6 +44,15 @@
"buildTarget": "blog-app:build:production"
}
}
},
"serve-nitro": {
"executor": "@nrwl/web:file-server",
"options": {
"buildTarget": "blog-app:build",
"parallel": true,
"port": 3000,
"staticFilePath": "dist/apps/blog-app/analog/public"
}
}
},
"tags": []
Expand Down
4 changes: 2 additions & 2 deletions apps/blog-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export default defineConfig(() => {
nitro: {
rootDir: 'apps/blog-app',
output: {
dir: '../../../dist/apps/blog-app/server',
publicDir: '../../../dist/apps/blog-app/server/public',
dir: '../../../dist/apps/blog-app/analog',
publicDir: '../../../dist/apps/blog-app/analog/public',
},
publicAssets: [{ dir: `../../../dist/apps/blog-app/client` }],
serverAssets: [
Expand Down
4 changes: 2 additions & 2 deletions apps/docs-app/docs/features/deployment/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ pnpm run build

## Build Artifacts

The client build artifacts are located in the `dist/client` directory. The server for the API routes are located in the `dist/server` directory.
The client build artifacts are located in the `dist/client` directory. The server for the API routes is located in the `dist/server` directory.

If you have [server side rendering](/docs/features/server/server-side-rendering) enabled, the client build artifacts are located in the `dist/server/public` directory. The server for the API/SSR build artifacts are located in the `dist/server/server` directory.
If you have [server side rendering](/docs/features/server/server-side-rendering) enabled, the client build artifacts are located in the `dist/analog/public` directory. The server for the API/SSR build artifacts is located in the `dist/analog/server` directory.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"@nrwl/jest": "15.7.0",
"@nrwl/linter": "15.7.0",
"@nrwl/vite": "15.7.0",
"@nrwl/web": "15.7.0",
"@nrwl/workspace": "15.7.0",
"@nx-plus/docusaurus": "15.0.0-rc.0",
"@schematics/angular": "~15.1.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/platform/src/lib/vite-nitro-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export function viteNitroPlugin(
srcDir: normalizePath(`${rootDir}/src`),
scanDirs: [normalizePath(`${rootDir}/src/server`)],
output: {
dir: '../dist/server',
publicDir: '../dist/server/public',
dir: '../dist/analog',
publicDir: '../dist/analog/public',
...nitroOptions?.output,
},
buildDir: './dist/.nitro',
Expand Down
Loading

0 comments on commit c8cbf24

Please sign in to comment.