1
1
// Karma configuration
2
2
3
- // Load Rollup dependencies
4
- const rollupConfig = {
5
- resolve : require ( 'rollup-plugin-node-resolve' ) ,
6
- commonjs : require ( 'rollup-plugin-commonjs' ) ,
7
- replace : require ( 'rollup-plugin-replace' ) ,
8
- babel : require ( 'rollup-plugin-babel' )
9
- }
10
-
11
3
module . exports = function ( config ) {
12
4
config . set ( {
13
5
@@ -22,11 +14,11 @@ module.exports = function(config) {
22
14
23
15
// list of files / patterns to load in the browser
24
16
files : [
25
- { pattern : 'src/index.js' , watched : false } ,
17
+ { pattern : 'src/index.js' , watched : false , served : true } ,
18
+ { pattern : 'test/**/*.js' , watched : true } ,
26
19
{ pattern : 'test/reference/*.*' , included : false , served : true } ,
27
20
{ pattern : require . resolve ( 'pdftest/dist/pdftest.client.min.js' ) , watched : false } ,
28
21
{ pattern : require . resolve ( 'pdftest/dist/chai-pdftest.min.js' ) , watched : false } ,
29
- 'test/**/*.js'
30
22
] ,
31
23
32
24
@@ -39,8 +31,8 @@ module.exports = function(config) {
39
31
// preprocess matching files before serving them to the browser
40
32
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
41
33
preprocessors : {
42
- 'src/index.js' : [ 'rollup ' ] ,
43
- 'test/**/*.js' : [ 'rollupTests ' ] ,
34
+ 'src/index.js' : [ 'webpack ' ] ,
35
+ 'test/**/*.js' : [ 'webpackTests ' ] ,
44
36
} ,
45
37
46
38
@@ -91,39 +83,34 @@ module.exports = function(config) {
91
83
} ,
92
84
93
85
94
- // Rollup preprocessor
95
- // Setup as a normal Rollup config object, just without the input
96
- // It has its own autoWatch behaviour, so Karma's file watcher must be disabled on its files
97
- rollupPreprocessor : {
86
+ webpackPreprocessor : {
98
87
output : {
99
- name : 'html2pdf' ,
100
- format : 'iife' ,
101
- globals : {
102
- jspdf : 'jsPDF' ,
103
- html2canvas : 'html2canvas'
104
- }
88
+ library : 'html2pdf' ,
89
+ libraryExport : 'default' ,
90
+ } ,
91
+ target : 'browserslist' ,
92
+ optimization : { minimize : false } ,
93
+ watch : true ,
94
+ module : {
95
+ rules : [
96
+ {
97
+ test : / \. m ? j s $ / ,
98
+ exclude : / n o d e _ m o d u l e s / ,
99
+ use : [ 'babel-loader' ] ,
100
+ } ,
101
+ ] ,
105
102
} ,
106
- plugins : [
107
- rollupConfig . resolve ( ) ,
108
- rollupConfig . commonjs ( ) ,
109
- rollupConfig . replace ( { 'process.env.NODE_ENV' : JSON . stringify ( 'production' ) } ) ,
110
- rollupConfig . babel ( { exclude : 'node_modules/**' } )
111
- ]
112
103
} ,
113
104
114
105
customPreprocessors : {
115
- rollupTests : {
116
- base : 'rollup ' ,
106
+ webpackTests : {
107
+ base : 'webpack ' ,
117
108
options : {
118
- output : {
119
- name : 'html2pdf_test' ,
120
- format : 'iife' ,
121
- globals : {
122
- html2pdf : 'html2pdf' ,
123
- } ,
124
- } ,
109
+ output : { } ,
110
+ externals : [ 'html2pdf' ] ,
111
+ externalsType : 'global' ,
125
112
} ,
126
113
} ,
127
114
} ,
128
- } )
115
+ } ) ;
129
116
}
0 commit comments