summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/rollup.config.test.js
blob: 9a706fc668b83f331a73fac5886a2d23b36bb43d (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
// rollup.config.js
import fs from 'fs';
import path from 'path';
import css from 'rollup-plugin-css-only';
import { makePlugins } from "./rollup.config"

function fromDir(startPath, regex) {
  if (!fs.existsSync(startPath)) {
    return;
  }
  const files = fs.readdirSync(startPath);
  const result = files.flatMap(file => {
    const filename = path.join(startPath, file);

    const stat = fs.lstatSync(filename);
    if (stat.isDirectory()) {
      return fromDir(filename, regex);
    }
    else if (regex.test(filename)) {
      return filename
    }
  }).filter(x => !!x)

  return result
}

const tests = fromDir('./src', /.test.ts$/)
  // .filter(t => t === 'src/wallet/DepositPage.test.ts')
  .map(test => ({
    input: test,
    output: {
      file: test.replace(/^src/, 'dist').replace(/\.ts$/, '.js'),
      format: "iife",
      exports: "none",
      name: test,
    },
    plugins: [
      ...makePlugins(),
      css({
        output: 'walletEntryPoint.css',
      }),
    ],
  }))

export default [
  ...tests,
];