-
-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vite-plugin-angular): expose esbuild entry point (#910)
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import analog from '@analogjs/vite-plugin-angular'; | ||
import type * as esbuild from 'esbuild'; | ||
|
||
export const analogSFC: () => esbuild.Plugin = () => ({ | ||
name: 'analog-sfc-esbuild-plugin', | ||
async setup(build) { | ||
const analogPlugins: any = analog({ | ||
experimental: { supportAnalogFormat: true }, | ||
}); | ||
|
||
const analogPlugin = analogPlugins[0]; | ||
await analogPlugin.config({ root: '.' }, { command: 'build' }); | ||
await analogPlugin.buildStart?.({ | ||
plugins: [ | ||
{ | ||
name: 'vite:css', | ||
transform(code: string) { | ||
return { code }; | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
build.onLoad({ filter: /.analog$/ }, async (args) => { | ||
await analogPlugin.handleHotUpdate?.({ file: args.path, modules: [] }); | ||
const result = await analogPlugin.transform?.('', args.path); | ||
return { loader: 'js', contents: result?.code }; | ||
}); | ||
}, | ||
}); |
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