1
- const commonjs = require ( 'rollup-plugin-commonjs' ) ;
2
- const inject = require ( 'rollup-plugin-inject' ) ;
3
- const json = require ( 'rollup-plugin-json' ) ;
4
- const nodeGlobals = require ( 'rollup-plugin-node-globals' ) ;
5
- const nodeResolve = require ( 'rollup-plugin-node-resolve' ) ;
6
- const replace = require ( 'rollup-plugin-replace' ) ;
7
- const typescript = require ( 'rollup-plugin-typescript2' ) ;
8
- const wasm = require ( 'rollup-plugin-wasm' ) ;
1
+ const path = require ( 'path' ) ;
2
+ const webpack = require ( 'webpack' ) ;
9
3
10
4
const packageJson = require ( './package.json' ) ;
11
5
@@ -17,52 +11,49 @@ module.exports = function(config) {
17
11
autoWatch : false ,
18
12
browsers : [ 'ChromeHeadless' ] ,
19
13
files : [
20
- { pattern : 'scripts/register-assert-browser.js' } ,
21
- { pattern : 'src/__tests__/index.ts' } ,
22
- { pattern : 'node_modules/virgil-crypto/dist/libfoundation.browser.wasm' , included : false }
14
+ 'scripts/register-assert-browser.js' ,
15
+ 'src/__tests__/index.ts' ,
23
16
] ,
24
- proxies : {
25
- '/base/src/__tests__/libfoundation.browser.wasm' : '/base/node_modules/virgil-crypto/dist/libfoundation.browser.wasm'
26
- } ,
27
17
colors : true ,
28
18
reporters : [ 'progress' ] ,
29
19
logLevel : config . LOG_INFO ,
30
20
browserNoActivityTimeout : 60 * 1000 ,
31
21
singleRun : true ,
22
+ mime : {
23
+ 'text/x-typescript' : [ 'ts' ] ,
24
+ 'application/wasm' : [ 'wasm' ] ,
25
+ } ,
32
26
preprocessors : {
33
- 'src/**/* .ts' : [ 'rollup ' ]
27
+ 'src/__tests__/index .ts' : [ 'webpack ' ]
34
28
} ,
35
- rollupPreprocessor : {
36
- output : {
37
- format : 'iife' ,
38
- name : 'virgil' ,
39
- sourcemap : false
40
- } ,
41
- plugins : [
42
- nodeResolve ( {
43
- browser : true ,
44
- extensions : [ '.js' , '.ts' ] ,
45
- } ) ,
46
- commonjs ( ) ,
47
- replace ( {
48
- 'process.browser' : JSON . stringify ( true ) ,
49
- 'process.env.VERSION' : JSON . stringify ( packageJson . version ) ,
50
- 'process.env.API_KEY_PRIVATE_KEY' : JSON . stringify ( process . env . API_KEY_PRIVATE_KEY ) ,
51
- 'process.env.API_KEY_ID' : JSON . stringify ( process . env . API_KEY_ID ) ,
52
- 'process.env.APP_ID' : JSON . stringify ( process . env . APP_ID ) ,
53
- 'process.env.API_URL' : JSON . stringify ( process . env . API_URL ) ,
54
- } ) ,
55
- typescript ( ) ,
56
- nodeGlobals ( ) ,
57
- inject ( {
58
- modules : {
59
- Buffer : [ 'buffer-es6' , 'Buffer' ] ,
60
- } ,
61
- } ) ,
62
- json ( ) ,
63
- // workaround. maybe there is a better way to handle it
64
- wasm ( )
65
- ]
66
- }
29
+ webpack : {
30
+ mode : 'production' ,
31
+ resolve : {
32
+ extensions : [ '.js' , '.ts' ] ,
33
+ } ,
34
+ module : {
35
+ rules : [
36
+ {
37
+ test : / \. t s $ / ,
38
+ loader : 'ts-loader' ,
39
+ } ,
40
+ {
41
+ test : / \. w a s m $ / ,
42
+ type : 'javascript/auto' ,
43
+ loader : 'file-loader' ,
44
+ } ,
45
+ ] ,
46
+ } ,
47
+ plugins : [
48
+ new webpack . EnvironmentPlugin ( {
49
+ browser : JSON . stringify ( true ) ,
50
+ VERSION : JSON . stringify ( packageJson . version ) ,
51
+ API_KEY_PRIVATE_KEY : JSON . stringify ( process . env . API_KEY_PRIVATE_KEY ) ,
52
+ API_KEY_ID : JSON . stringify ( process . env . API_KEY_ID ) ,
53
+ APP_ID : JSON . stringify ( process . env . APP_ID ) ,
54
+ API_URL : JSON . stringify ( process . env . API_URL ) ,
55
+ } ) ,
56
+ ] ,
57
+ } ,
67
58
} ) ;
68
59
} ;
0 commit comments