summaryrefslogtreecommitdiff
path: root/contrib/build-fast-with-linaria.mjs
blob: 88ce75f181354b22a87e18f85106c40e2b05bfb0 (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

import linaria from '@linaria/esbuild'
import esbuild from 'esbuild'

if (process.argv.length !== 4) {
  console.log(`
Usage:
  ${process.argv[1]} <entryPoint> <outDir>

entryPoint: file to be converted
outputDir: destination directory
`)
  process.exit(1)
}

esbuild
  .build({
    entryPoints: [process.argv[2]],
    bundle: true,
    outdir: process.argv[3],
    minify: false,
    nodePaths: ['build/web', 'vendor'],
    loader: {
      '.svg': 'dataurl',
      '.png': 'dataurl',
    },
    target: [
      'esnext'
    ],
    format: 'esm',
    jsxFactory: 'h',
    jsxFragment: 'Fragment',
    define: {
      'process.env.NODE_ENV' : '"development"',
    },
    plugins: [
      linaria.default({
        sourceMap: true,
      }),
    ],
  })
  .catch (() => process.exit(1));