Skip to content

Commit d04536b

Browse files
committed
add support for passing es build overrides
1 parent 5530ffe commit d04536b

File tree

4 files changed

+38
-30
lines changed

4 files changed

+38
-30
lines changed

README.md

+24-19
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@ npm install --save-dev @yarbsemaj/adapter-lambda
1111
In your `svelte.config.js` configure the adapter as below;
1212

1313
```js
14-
import preprocess from 'svelte-preprocess'; //Optional
1514
import serverless from '@yarbsemaj/adapter-lambda';
15+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
1616

1717
/** @type {import('@sveltejs/kit').Config} */
1818
const config = {
19-
preprocess: preprocess(), //Optional
20-
21-
kit: {
22-
adapter: serverless(),
23-
},
19+
preprocess: vitePreprocess(),
2420

21+
kit: {
22+
adapter: serverless() //See Below for optional arguments
23+
}
2524
};
2625

2726
export default config;
@@ -44,6 +43,12 @@ An example project using cdk can be found [here](https://github.com/yarbsemaj/sv
4443
### Tada 🎉
4544
No matter how you deploy, your app can then be accessed via the CloudFront distribution created as a part of the stack.
4645

46+
## Options
47+
| Argument | Description | Type | Default |
48+
| ------------------- | ------------------------------------------ | ------- | ------- |
49+
| **out** | the output directory of build files | string | out |
50+
| **esbuildOverride** | overrides for the [default esbuild options](https://github.com/yarbsemaj/sveltekit-adapter-lambda/blob/master/index.js#L69) | [esbuild Build Options](https://github.com/evanw/esbuild/blob/fc37c2fa9de2ad77476a6d4a8f1516196b90187e/lib/shared/types.ts#L110) | {} |
51+
4752
## Static Assets and precompiled pages
4853
To server static assets and precompiled pages, this adapter makes use of S3. In order to route traffic to the correct destination a Lambda@edge function is used to perform an origin rewrite to redirect traffic to the S3 Bucket.
4954

@@ -55,16 +60,16 @@ To server static assets and precompiled pages, this adapter makes use of S3. In
5560
Please raise an issue on [Github](https://github.com/yarbsemaj/sveltekit-adapter-lambda/issues), and I will be happy to issue a fix.
5661

5762
## Versions
58-
| Adapter Version| Sveltekit Version |
59-
| ---------------| ----------------- |
60-
| 1.1.x - 1.2.x | 1.22.0 (Official) |
61-
| 1.x.x | 1.0.0 (Official) |
62-
| 0.12.x | 1.0.0-next.433 |
63-
| 0.11.x | 1.0.0-next.401 |
64-
| 0.10.x | 1.0.0-next.380 |
65-
| 0.9.x | 1.0.0-next.348 |
66-
| 0.6.x - 0.8.x | 1.0.0-next.301 |
67-
| 0.5.x | 1.0.0-next.286 |
68-
| 0.3.x - 0.4.x | 1.0.0-next.286 |
69-
| 0.2.x | 1.0.0-next.239 |
70-
| 0.1.x | 1.0.0-next.169 |
63+
| Adapter Version | Sveltekit Version |
64+
| --------------- | ----------------- |
65+
| 1.1.x - 1.2.x | 1.22.0 (Official) |
66+
| 1.x.x | 1.0.0 (Official) |
67+
| 0.12.x | 1.0.0-next.433 |
68+
| 0.11.x | 1.0.0-next.401 |
69+
| 0.10.x | 1.0.0-next.380 |
70+
| 0.9.x | 1.0.0-next.348 |
71+
| 0.6.x - 0.8.x | 1.0.0-next.301 |
72+
| 0.5.x | 1.0.0-next.286 |
73+
| 0.3.x - 0.4.x | 1.0.0-next.286 |
74+
| 0.2.x | 1.0.0-next.239 |
75+
| 0.1.x | 1.0.0-next.169 |

index.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ const esbuild = require('esbuild');
66
/**
77
* @param {{
88
* out?: string;
9+
* esbuildOverride?: import('esbuild').BuildOptions;
910
* }} options
1011
*/
11-
module.exports = function ({ out = 'build' } = {}) {
12+
module.exports = function ({ out = 'build', esbuildOverride = {} } = {}) {
1213
/** @type {import('@sveltejs/kit').Adapter} */
1314
const adapter = {
1415
name: 'adapter-serverless',
@@ -47,13 +48,15 @@ module.exports = function ({ out = 'build' } = {}) {
4748

4849
builder.log.minor('Building lambda');
4950
esbuild.buildSync({
50-
entryPoints: [`${server_directory}/_serverless.js`],
51-
outfile: `${server_directory}/serverless.js`,
52-
inject: [join(`${server_directory}/shims.js`)],
53-
external: ['node:*'],
54-
format: 'cjs',
55-
bundle: true,
56-
platform: 'node',
51+
...{
52+
entryPoints: [`${server_directory}/_serverless.js`],
53+
outfile: `${server_directory}/serverless.js`,
54+
inject: [join(`${server_directory}/shims.js`)],
55+
external: ['node:*'],
56+
format: 'cjs',
57+
bundle: true,
58+
platform: 'node',
59+
}, ...esbuildOverride
5760
});
5861

5962
builder.log.minor('Prerendering static pages');

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@yarbsemaj/adapter-lambda",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"license": "MIT",
55
"description": "An adapter for [SvelteKit](https://kit.svelte.dev/) for AWS Lambda. [Serverless](https://www.serverless.com/) or [CDK](https://aws.amazon.com/cdk/) deployment.",
66
"repository": {

0 commit comments

Comments
 (0)