所以我很难让这个组件在 webpack 环境中工作。
基本上,当您按照 readme.md 中的指示导入时 - 结果是一个空对象。
import Vibrant from 'node-vibrant/dist/vibrant.worker';
console.log(Vibrant) // returns {}
import Vibrant from 'node-vibrant/dist/vibrant.worker.min';
console.log(Vibrant) // returns {}
// Normal import - works fine... (just doesn't seem to have the worker functionality...)
import Vibrant from 'node-vibrant';
console.log(Vibrant) /* returns ƒ Vibrant(_src, opts) {
this._src = _src;
this.opts = defaults({}, opts, Vibrant.DefaultOpts);
this.opts.combinedFilter = Filters.combineFilters(this.opts.filters);
} */
您对如何修复有任何想法吗?
这个问题有解决方法吗?
引用 #85 中的@akfish :
我们仍在最终确定文档。
您将需要 webpack 和 worker-loader 才能工作。
相关文档在开发分支中:
https://github.com/akfish/node-vibrant/tree/develop#webpack -configuration
这也应该部分是由在3.1
版本中被压缩的一些错误引起的。 如果您仍然遇到问题,请尝试更新包
具体应该在哪里加规则,就不说了。 我的意思是在哪个文件中添加规则是正确的?
{
// ...
module: {
rules: [
{
test: /\.worker.js$/,
loader: 'worker-loader',
options: { /* ... */ }
},
// ...
]
}
}
应该进入你的 webpack 配置。
https://webpack.js.org/concepts/loaders/ 可能是一个很好的资源来找到更多:)
最有用的评论
应该进入你的 webpack 配置。
https://webpack.js.org/concepts/loaders/ 可能是一个很好的资源来找到更多:)