aboutsummaryrefslogtreecommitdiff
path: root/src/build_ffi.mjs
blob: d60f1dd5eed17c5138b8b43508c1d737b2c60773 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { build } from 'esbuild'
import { lessLoader } from 'esbuild-plugin-less';

export async function bundle_build(entry, out) {
  await build({
    entryPoints: [entry],
    bundle: true,
    minify: true,
    format: 'esm',
    outfile: out,
  })
}

export async function js_build(js, out) {
  await build({
    stdin: {
      contents: js,
      loader: 'js',
    },
    bundle: false,
    minify: false,
    format: 'esm',
    outfile: out,
  })
}

export async function wxml_build(wxml, out) {
  await build({
    entryPoints: [wxml],
    loader: 'txt',
    outfile: out,
  })
}

export async function json_build(json, out) {
  await build({
    entryPoints: [json],
    loader: 'json',
    outfile: out,
  })
}

export async function less_build(css, out) {
  await build({
    entryPoints: [css],
    plugins: [lessLoader()],
    loader: 'css',
    outfile: out,
  })
}