diff --git a/packages/remix/src/generators/application/application.impl.ts b/packages/remix/src/generators/application/application.impl.ts index a1495d302a772..a3377ce50698b 100644 --- a/packages/remix/src/generators/application/application.impl.ts +++ b/packages/remix/src/generators/application/application.impl.ts @@ -93,6 +93,13 @@ export async function remixApplicationGeneratorInternal( cwd: options.projectRoot, }, }, + ['static-serve']: { + dependsOn: ['build'], + command: `remix-serve build/index.js`, + options: { + cwd: options.projectRoot, + }, + }, typecheck: { command: `tsc --project tsconfig.app.json`, options: { diff --git a/packages/remix/src/generators/application/lib/add-e2e.ts b/packages/remix/src/generators/application/lib/add-e2e.ts index 99199bc42f1e0..6f5fec99e607c 100644 --- a/packages/remix/src/generators/application/lib/add-e2e.ts +++ b/packages/remix/src/generators/application/lib/add-e2e.ts @@ -16,10 +16,6 @@ export async function addE2E(tree: Tree, options: NormalizedSchema) { typeof import('@nx/cypress') >('@nx/cypress', getPackageVersion(tree, 'nx')); - // TODO(colum): Remix needs a different approach to serve-static - // Likely via remix start - // addFileServerTarget(tree, options, 'serve-static'); - addProjectConfiguration(tree, options.e2eProjectName, { projectType: 'application', root: options.e2eProjectRoot, @@ -70,19 +66,3 @@ export async function addE2E(tree: Tree, options: NormalizedSchema) { return () => {}; } } - -function addFileServerTarget( - tree: Tree, - options: NormalizedSchema, - targetName: string -) { - const projectConfig = readProjectConfiguration(tree, options.projectName); - projectConfig.targets[targetName] = { - executor: '@nx/web:file-server', - options: { - buildTarget: `${options.projectName}:build`, - port: options.e2ePort, - }, - }; - updateProjectConfiguration(tree, options.projectName, projectConfig); -} diff --git a/packages/remix/src/plugins/__snapshots__/plugin.spec.ts.snap b/packages/remix/src/plugins/__snapshots__/plugin.spec.ts.snap index f3be62899e917..5c699c988a110 100644 --- a/packages/remix/src/plugins/__snapshots__/plugin.spec.ts.snap +++ b/packages/remix/src/plugins/__snapshots__/plugin.spec.ts.snap @@ -39,6 +39,15 @@ exports[`@nx/remix/plugin non-root project should create nodes 1`] = ` "cwd": "my-app", }, }, + "static-serve": { + "command": "remix-serve build/index.js", + "dependsOn": [ + "build", + ], + "options": { + "cwd": "my-app", + }, + }, "tsc": { "cache": true, "command": "tsc", @@ -95,6 +104,15 @@ exports[`@nx/remix/plugin root project should create nodes 1`] = ` "cwd": ".", }, }, + "static-serve": { + "command": "remix-serve build/index.js", + "dependsOn": [ + "build", + ], + "options": { + "cwd": ".", + }, + }, "typecheck": { "cache": true, "command": "tsc", diff --git a/packages/remix/src/plugins/plugin.spec.ts b/packages/remix/src/plugins/plugin.spec.ts index 0094174e94c30..4192b4e206989 100644 --- a/packages/remix/src/plugins/plugin.spec.ts +++ b/packages/remix/src/plugins/plugin.spec.ts @@ -69,6 +69,7 @@ module.exports = { devTargetName: 'dev', startTargetName: 'start', typecheckTargetName: 'typecheck', + staticServeTargetName: 'static-serve', }, context ); @@ -128,6 +129,7 @@ module.exports = { devTargetName: 'dev', startTargetName: 'start', typecheckTargetName: 'tsc', + staticServeTargetName: 'static-serve', }, context ); diff --git a/packages/remix/src/plugins/plugin.ts b/packages/remix/src/plugins/plugin.ts index dd8f6e633703a..9515693f450f1 100644 --- a/packages/remix/src/plugins/plugin.ts +++ b/packages/remix/src/plugins/plugin.ts @@ -47,6 +47,7 @@ export interface RemixPluginOptions { devTargetName?: string; startTargetName?: string; typecheckTargetName?: string; + staticServeTargetName?: string; } export const createNodes: CreateNodes = [ @@ -118,6 +119,11 @@ async function buildRemixTargets( serverBuildPath, options.buildTargetName ); + targets[options.staticServeTargetName] = startTarget( + projectRoot, + serverBuildPath, + options.buildTargetName + ); targets[options.typecheckTargetName] = typecheckTarget( projectRoot, namedInputs, @@ -228,6 +234,7 @@ function normalizeOptions(options: RemixPluginOptions) { options.devTargetName ??= 'dev'; options.startTargetName ??= 'start'; options.typecheckTargetName ??= 'typecheck'; + options.staticServeTargetName ??= 'static-serve'; return options; }