-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow output directories to be overridden (#110)
* Made output directories overridable * Added output directory tests
- Loading branch information
1 parent
73ee5a1
commit 91ca74f
Showing
10 changed files
with
93 additions
and
39 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 @@ | ||
custom-output-directory |
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
playground/multi-worker/__tests__/custom-output-directories/multi-worker.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,20 @@ | ||
import * as fs from 'node:fs'; | ||
import * as path from 'node:path'; | ||
import { describe, expect, test } from 'vitest'; | ||
import { getJsonResponse, isBuild, rootDir } from '../../../__test-utils__'; | ||
|
||
describe.runIf(isBuild)('output directories', () => { | ||
test('creates the correct output directories', () => { | ||
expect(fs.existsSync(path.join(rootDir, 'dist', 'worker_a'))).toBe(true); | ||
expect(fs.existsSync(path.join(rootDir, 'custom-output-directory'))).toBe( | ||
true, | ||
); | ||
}); | ||
}); | ||
|
||
describe('multi-worker service bindings', async () => { | ||
test('returns a response from another worker', async () => { | ||
const result = await getJsonResponse('/fetch'); | ||
expect(result).toEqual({ result: { name: 'Worker B' } }); | ||
}); | ||
}); |
18 changes: 17 additions & 1 deletion
18
...worker/__tests__/service-bindings.spec.ts → ...lti-worker/__tests__/multi-worker.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
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"extends": ["@vite-plugin-cloudflare/typescript-config/base.json"], | ||
"include": ["vite.config.ts", "__tests__"] | ||
"include": [ | ||
"vite.config.ts", | ||
"vite.config.custom-output-directories.ts", | ||
"__tests__" | ||
] | ||
} |
19 changes: 19 additions & 0 deletions
19
playground/multi-worker/vite.config.custom-output-directories.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,19 @@ | ||
import { cloudflare } from '@flarelabs-net/vite-plugin-cloudflare'; | ||
import { defineConfig } from 'vite'; | ||
|
||
export default defineConfig({ | ||
environments: { | ||
worker_b: { | ||
build: { | ||
outDir: 'custom-output-directory', | ||
}, | ||
}, | ||
}, | ||
plugins: [ | ||
cloudflare({ | ||
configPath: './worker-a/wrangler.toml', | ||
auxiliaryWorkers: [{ configPath: './worker-b/wrangler.toml' }], | ||
persistState: false, | ||
}), | ||
], | ||
}); |