aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/rollup.config.js
blob: 8945b48ace5e00a5b2829afecc00eb11048a4b82 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// rollup.config.js
import linaria from '@linaria/rollup';
import alias from '@rollup/plugin-alias';
import commonjs from "@rollup/plugin-commonjs";
import image from '@rollup/plugin-image';
import json from "@rollup/plugin-json";
import nodeResolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
import css from 'rollup-plugin-css-only';
import ignore from "rollup-plugin-ignore";
import typescript from '@rollup/plugin-typescript';

export const makePlugins = () => [
  typescript({
    outputToFilesystem: false,
  }),

  alias({
    entries: [
      { find: 'react', replacement: 'preact/compat' },
      { find: 'react-dom', replacement: 'preact/compat' }
    ]
  }),

  ignore(["module", "os"]),
  nodeResolve({
    browser: true,
    preferBuiltins: true,
  }),

  //terser(),


  replace({
    "process.env.NODE_ENV": JSON.stringify("production"),
    // "__filename": "'__webextension__'",
    preventAssignment: true
  }),

  commonjs({
    include: [/node_modules/, /dist/],
    extensions: [".js"],
    ignoreGlobal: true,
    sourceMap: true,
  }),

  json(),
  image(),

  linaria({
    babelOptions: {
      babelrc: false,
      configFile: './babel.config-linaria.json',
    },
    sourceMap: process.env.NODE_ENV !== 'production',
  }),

];


const webExtensionWalletEntryPoint = {
  input: "src/walletEntryPoint.tsx",
  output: {
    file: "dist/walletEntryPoint.js",
    format: "iife",
    exports: "none",
    name: "webExtensionWalletEntry",
  },
  plugins: [
    ...makePlugins(),
    css({
      output: 'walletEntryPoint.css',
    }),
  ],
};

const webExtensionPopupEntryPoint = {
  input: "src/popupEntryPoint.tsx",
  output: {
    file: "dist/popupEntryPoint.js",
    format: "iife",
    exports: "none",
    name: "webExtensionPopupEntry",
  },
  plugins: [
    ...makePlugins(),
    css({
      output: 'popupEntryPoint.css',
    }),
  ],
};

const webExtensionBackgroundPageScript = {
  input: "src/background.ts",
  output: {
    file: "dist/background.js",
    format: "iife",
    exports: "none",
    name: "webExtensionBackgroundScript",
  },
  plugins: makePlugins(),
};

const webExtensionCryptoWorker = {
  input: "src/browserWorkerEntry.ts",
  output: {
    file: "dist/browserWorkerEntry.js",
    format: "iife",
    exports: "none",
    name: "webExtensionCryptoWorker",
  },
  plugins: makePlugins(),
};


export default [
  webExtensionPopupEntryPoint,
  webExtensionWalletEntryPoint,
  webExtensionBackgroundPageScript,
  webExtensionCryptoWorker,
];