@@ -16,6 +16,10 @@ function getFactoryFuncName(options) {
16
16
}
17
17
18
18
function getArgsString ( source , sourcemap , options ) {
19
+ if ( options . targetPlatform === 'base64' ) {
20
+ return Buffer . from ( source , options . enableUnicode ? 'utf16le' : 'utf8' ) . toString ( 'base64' ) ;
21
+ }
22
+
19
23
if ( options . inline ) {
20
24
const sourcemapArg = sourcemap ? `'${ sourcemap . toUrl ( ) } '` : 'null' ;
21
25
if ( options . preserveSource ) {
@@ -27,10 +31,15 @@ function getArgsString(source, sourcemap, options) {
27
31
return `'${ source } '` ;
28
32
}
29
33
30
- function buildWorkerCode ( source , sourcemap = null , optionsArg = kDefaultsOptions ) {
31
- const options = Object . assign ( { } , kDefaultsOptions , optionsArg ) ;
32
- const factoryFuncName = getFactoryFuncName ( options ) ;
33
- const argsString = getArgsString ( source , sourcemap , options ) ;
34
+ function buildWorkerSource ( options , factoryFuncName , argsString ) {
35
+ if ( options . targetPlatform === 'base64' ) {
36
+ return `
37
+ /* eslint-disable */
38
+ var base64 = '${ argsString } ';
39
+ export default base64;
40
+ /* eslint-enable */\n` ;
41
+ }
42
+
34
43
return `
35
44
/* eslint-disable */
36
45
import {${ factoryFuncName } } from '\0rollup-plugin-web-worker-loader::helper::${ options . targetPlatform } ::${ factoryFuncName } ';
@@ -39,4 +48,11 @@ export default WorkerFactory;
39
48
/* eslint-enable */\n` ;
40
49
}
41
50
51
+ function buildWorkerCode ( source , sourcemap = null , optionsArg = kDefaultsOptions ) {
52
+ const options = Object . assign ( { } , kDefaultsOptions , optionsArg ) ;
53
+ const factoryFuncName = getFactoryFuncName ( options ) ;
54
+ const argsString = getArgsString ( source , sourcemap , options ) ;
55
+ return buildWorkerSource ( options , factoryFuncName , argsString ) ;
56
+ }
57
+
42
58
module . exports = buildWorkerCode ;
0 commit comments