Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/esmfile/esbuild-plugin-esmfile
Import *.file.ts/*.file.js modules to build files using the file loader...For example, importing rocket-launch.svg.file.ts builds rocket-launch.svg in the build output directory during build time.
https://github.com/esmfile/esbuild-plugin-esmfile
Last synced: 3 months ago
JSON representation
Import *.file.ts/*.file.js modules to build files using the file loader...For example, importing rocket-launch.svg.file.ts builds rocket-launch.svg in the build output directory during build time.
- Host: GitHub
- URL: https://github.com/esmfile/esbuild-plugin-esmfile
- Owner: esmfile
- License: apache-2.0
- Created: 2024-02-19T06:20:45.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-05-23T07:44:10.000Z (6 months ago)
- Last Synced: 2024-05-23T08:49:48.391Z (6 months ago)
- Language: TypeScript
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[//]: @formatter:off
# esmfileImport *.file.ts/*.file.js modules to build files using the file loader...For example, importing rocket-launch.svg.file.ts builds rocket-launch.svg in the build output directory during build time.
## install
```
npm i -D esbuild-plugin-esmfile
```## usage
Build file
```ts
import { build } from 'esbuild'
import esmfile from 'esbuild-plugin-esmfile'
await build({
entryPoints: [/* source code entry point */],
plugins: [esmfile()]
})
```Component file
```ts
import rocket_launch_svg from './rocket-launch.svg.file.js?stroke=green'
// rocket_launch_svg is the path to the rocket-launch-[hash].svg
// file in the esbuild output directory.
// The stroke of the icon is green.
export function html_() {
return `
`.trim()
}
```rocket-launch.svg.file.ts
```ts
export default ()=>{
const url = new URL(import.meta.url)
const stroke = url.searchParams.get('stroke') ?? 'currentColor'
// language=svg
return (
''
)
}
```
[//]: @formatter:on