11// Karma configuration
22
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-
113module . exports = function ( config ) {
124 config . set ( {
135
@@ -22,11 +14,11 @@ module.exports = function(config) {
2214
2315 // list of files / patterns to load in the browser
2416 files : [
25- { pattern : 'src/index.js' , watched : false } ,
17+ { pattern : 'src/index.js' , watched : false , served : true } ,
18+ { pattern : 'test/**/*.js' , watched : true } ,
2619 { pattern : 'test/reference/*.*' , included : false , served : true } ,
2720 { pattern : require . resolve ( 'pdftest/dist/pdftest.client.min.js' ) , watched : false } ,
2821 { pattern : require . resolve ( 'pdftest/dist/chai-pdftest.min.js' ) , watched : false } ,
29- 'test/**/*.js'
3022 ] ,
3123
3224
@@ -39,8 +31,8 @@ module.exports = function(config) {
3931 // preprocess matching files before serving them to the browser
4032 // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
4133 preprocessors : {
42- 'src/index.js' : [ 'rollup ' ] ,
43- 'test/**/*.js' : [ 'rollupTests ' ] ,
34+ 'src/index.js' : [ 'webpack ' ] ,
35+ 'test/**/*.js' : [ 'webpackTests ' ] ,
4436 } ,
4537
4638
@@ -91,39 +83,34 @@ module.exports = function(config) {
9183 } ,
9284
9385
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 : {
9887 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+ ] ,
105102 } ,
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- ]
112103 } ,
113104
114105 customPreprocessors : {
115- rollupTests : {
116- base : 'rollup ' ,
106+ webpackTests : {
107+ base : 'webpack ' ,
117108 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' ,
125112 } ,
126113 } ,
127114 } ,
128- } )
115+ } ) ;
129116}
0 commit comments