esbuild-plugin-http-fetch
example
shcurl -o hello.jsx https://scrapbox.io/api/code/takker/esbuild-plugin-http-fetch/hello.jsx
deno run --prompt https://scrapbox.io/api/code/takker/esbuild-plugin-http-fetch/test.js
test.js// test/index.js
import {build, stop} from 'https://deno.land/x/esbuild@v0.12.1/mod.js'
import httpFetch from 'https://deno.land/x/esbuild_plugin_http_fetch@v1.0.2/index.js'
let {outputFiles} = await build({
bundle: true,
entryPoints: ['hello.jsx'],
jsxFactory: 'h',
plugins: [httpFetch],
write: false
})
console.log(outputFiles[0].text)
stop()
hello.jsx// test/hello.jsx
import {h} from 'https://unpkg.com/preact@10.5.13/dist/preact.module.js'
import render from 'https://unpkg.com/preact-render-to-string@5.1.19/dist/index.module.js?module'
let app = <h1>Hello, world!</h1>
let html = render(app)
console.log('expected: %s', '<h1>Hello, world!</h1>')
console.log('actual: %s', html)
CSS importも使えるのだろうか?
2021-07-06 05:50:36 成功した!
shdeno run -A -r=https://scrapbox.io/api/code/takker/esbuild-plugin-http-fetch/test_css.ts https://scrapbox.io/api/code/takker/esbuild-plugin-http-fetch/test_css.ts
test_css.tsimport {build, stop} from 'https://deno.land/x/esbuild@v0.12.1/mod.js'
import httpFetch from 'https://deno.land/x/esbuild_plugin_http_fetch@v1.0.2/index.js'
await Deno.writeTextFile('test.css', '@import \'https://scrapbox.io/api/code/takker/import/style.css\';');
const {outputFiles} = await build({
bundle: true,
minify: true,
entryPoints: ['test.css'],
plugins: [httpFetch],
write: false,
});
console.log(outputFiles[0].text);
stop();