Fix worker cross domain issue
This commit is contained in:
10
src/utils/getEnvironment.js
Normal file
10
src/utils/getEnvironment.js
Normal file
@@ -0,0 +1,10 @@
|
||||
module.exports = (key) => {
|
||||
const env = {
|
||||
type: (typeof window !== 'undefined') && (typeof window.document !== 'undefined') ? 'browser' : 'node',
|
||||
};
|
||||
|
||||
if (typeof key === 'undefined') {
|
||||
return env;
|
||||
}
|
||||
return env[key];
|
||||
};
|
||||
12
src/utils/resolvePaths.js
Normal file
12
src/utils/resolvePaths.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const isBrowser = require('./getEnvironment')('type') === 'browser';
|
||||
const resolveURL = isBrowser ? require('resolve-url') : s => s; // eslint-disable-line
|
||||
|
||||
module.exports = (options) => {
|
||||
const opts = { ...options };
|
||||
['corePath', 'workerPath'].forEach((key) => {
|
||||
if (typeof options[key] !== 'undefined') {
|
||||
opts[key] = resolveURL(opts[key]);
|
||||
}
|
||||
});
|
||||
return opts;
|
||||
};
|
||||
Reference in New Issue
Block a user