diff options
Diffstat (limited to 'rollup.config.js')
-rw-r--r-- | rollup.config.js | 186 |
1 files changed, 161 insertions, 25 deletions
diff --git a/rollup.config.js b/rollup.config.js index cfe0a4b8a..e88ad5ce3 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,56 +1,192 @@ // rollup.config.js -import commonjs from 'rollup-plugin-commonjs'; -import nodeResolve from 'rollup-plugin-node-resolve'; -import json from '@rollup/plugin-json'; -import builtins from 'builtin-modules' +import commonjs from "rollup-plugin-commonjs"; +import nodeResolve from "rollup-plugin-node-resolve"; +import json from "@rollup/plugin-json"; +import replace from "@rollup/plugin-replace"; +import builtins from "builtin-modules"; +import { terser } from "rollup-plugin-terser"; const walletCli = { - input: 'dist/node/headless/taler-wallet-cli.js', + input: "dist/node/headless/taler-wallet-cli.js", output: { - file: 'dist/standalone/taler-wallet-cli.js', - format: 'cjs' + file: "dist/standalone/taler-wallet-cli.js", + format: "cjs", }, external: builtins, plugins: [ + commonjs({ + include: ["node_modules/**", "src/**"], + extensions: [".js", ".ts"], + ignoreGlobal: false, // Default: false + sourceMap: false, + ignore: ["taler-wallet"], + }), nodeResolve({ preferBuiltins: true, }), + + json(), + ], +}; + +const walletAndroid = { + input: "dist/node/android/index.js", + output: { + file: "dist/standalone/taler-wallet-android.js", + format: "cjs", + exports: "named", + }, + external: builtins, + plugins: [ + json(), + + nodeResolve({ + preferBuiltins: true, + }), + commonjs({ - include: ['node_modules/**', 'dist/node/**'], - extensions: [ '.js' ], - ignoreGlobal: false, // Default: false + include: ["node_modules/**", "dist/node/**"], + extensions: [".js"], + ignoreGlobal: false, // Default: false sourceMap: false, - ignore: [ 'taler-wallet' ] + ignore: ["taler-wallet"], }), + ], +}; +const webExtensionPageEntryPoint = { + input: "dist/node/webex/pageEntryPoint.js", + output: { + file: "dist/webextension/pageEntryPoint.js", + format: "iife", + exports: "default", + name: "webExtensionPageEntry", + }, + external: builtins, + plugins: [ json(), - ] + nodeResolve({ + preferBuiltins: true, + }), + + terser(), + + replace({ + "process.env.NODE_ENV": JSON.stringify("production"), + }), + + commonjs({ + include: ["node_modules/**", "dist/node/**"], + extensions: [".js"], + ignoreGlobal: false, // Default: false + sourceMap: false, + ignore: ["taler-wallet"], + }), + ], }; -const walletAndroid = { - input: 'dist/node/android/index.js', +const webExtensionBackgroundPageScript = { + input: "dist/node/webex/background.js", output: { - file: 'dist/standalone/taler-wallet-android.js', - format: 'cjs', - exports: 'named', + file: "dist/webextension/background.js", + format: "iife", + exports: "default", + name: "webExtensionBackgroundScript", }, external: builtins, plugins: [ json(), nodeResolve({ - preferBuiltins: true + preferBuiltins: true, + }), + + terser(), + + replace({ + "process.env.NODE_ENV": JSON.stringify("production"), }), commonjs({ - include: ['node_modules/**', 'dist/node/**'], - extensions: [ '.js' ], - ignoreGlobal: false, // Default: false + include: ["node_modules/**", "dist/node/**"], + extensions: [".js"], + ignoreGlobal: false, // Default: false sourceMap: false, - ignore: [ 'taler-wallet' ] - }) - ] + ignore: ["taler-wallet", "crypto"], + }), + ], +}; + +const webExtensionCryptoWorker = { + input: "dist/node/crypto/workers/browserWorkerEntry.js", + output: { + file: "dist/webextension/browserWorkerEntry.js", + format: "iife", + exports: "default", + name: "webExtensionCryptoWorker", + }, + external: builtins, + plugins: [ + json(), + + nodeResolve({ + preferBuiltins: true, + }), + + terser(), + + replace({ + "process.env.NODE_ENV": JSON.stringify("production"), + }), + + commonjs({ + include: ["node_modules/**", "dist/node/**"], + extensions: [".js"], + ignoreGlobal: false, // Default: false + sourceMap: false, + ignore: ["taler-wallet", "crypto"], + }), + ], +}; + +const webExtensionContentScript = { + input: "dist/node/webex/notify.js", + output: { + file: "dist/webextension/contentScript.js", + format: "iife", + exports: "default", + name: "webExtensionContentScript", + }, + external: builtins, + plugins: [ + json(), + + nodeResolve({ + preferBuiltins: true, + }), + + terser(), + + replace({ + "process.env.NODE_ENV": JSON.stringify("production"), + }), + + commonjs({ + include: ["node_modules/**", "dist/node/**"], + extensions: [".js"], + ignoreGlobal: false, // Default: false + sourceMap: false, + ignore: ["taler-wallet"], + }), + ], }; -export default [walletCli, walletAndroid]; +export default [ + walletCli, + walletAndroid, + webExtensionPageEntryPoint, + webExtensionBackgroundPageScript, + webExtensionCryptoWorker, + webExtensionContentScript, +]; |