-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.app.js
More file actions
39 lines (34 loc) · 1.19 KB
/
rollup.config.app.js
File metadata and controls
39 lines (34 loc) · 1.19 KB
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
import typescript from 'rollup-plugin-typescript2'
// Cordova Library Configuration
const expectedCordovaModules = ["cordova-powerauth-mobile-sdk", "cordova", "cordova-powerauth-networking", "cordova-digital-onboarding", "iproov-cordova-plugin", "blinkid-cordova-plugin"]
// Cordova App Configuration
const appCordovaDir = 'testapp-cordova'
// We dont want to import modules that will be supplied by Cordova environment
// Cordova plugins are injected at runtime, so we need to strip these imports from the final bundle to not cause errors.
const stripCordovaImportsPlugin = {
name: "remove-cordova-modules",
transform(code, id) {
return {
code: code.replace(new RegExp(`^import.*(?:${expectedCordovaModules.map(m => `"${m}"`).join("|")}).*$`, "gm"), ""),
map: null,
};
},
}
// Generate both the JavaScript bundle and the TypeScript declaration file
export default [
// Cordova App
{
input: `${appCordovaDir}/src/index.ts`,
output: {
file: `${appCordovaDir}/www/js/index.js`,
format: 'cjs',
sourcemap: true
},
plugins: [
typescript({
tsconfig: `${appCordovaDir}/tsconfig.json`
}),
stripCordovaImportsPlugin
]
}
]