我正在尝试在Web worker中使用RequireJS.问题是我在使用它时不断收到以下错误.Uncaught Error: importScripts failed for underscore at ./lib/underscore.js
我已经测试了我的配置选项,它们只在导入Underscore时导致此错误.他们来了:
{
baseUrl: './',
paths: {
jquery: 'lib/jquery',
underscore: 'lib/underscore'
},
shim: {
underscore: {
exports: '_'
}
}
}
Run Code Online (Sandbox Code Playgroud)
如有必要,我可以添加更多信息.该项目的源代码在GitHub上,网址为https://github.com/isaach1000/canvas.
更新:修复RequireJS仍然没有运气,但我使用Grunt任务修复了我的问题.这是配置:
requirejs: {
worker: {
options: {
baseUrl: 'js',
name: 'task',
out: 'build/task.js',
paths: {
jquery: 'lib/jquery',
underscore: 'lib/underscore'
},
shim: {
underscore: {
exports: '_'
}
},
include: ['lib/require.js'],
optimize: 'none'
}
}
}
Run Code Online (Sandbox Code Playgroud)