require('datatables'); does not work
@H_404_5@我正在努力将jQuery-Datatables作为bower的webpack模块包含在内,目前的设置与其他bower组件一起使用,这里是webpack配置文件的一部分:
module.exports = { plugins: [ new webpack.ResolverPlugin( new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json",["main"]) ) ],resolve: { modulesDirectories: ['node_modules','bower_components'] } };
@H_404_5@
最佳答案
问题是DirectoryDescriptionFilePlugin需要主字段中的单个字符串条目,而datatables的bower.json声明一个数组:
"main": [ "media/js/jquery.dataTables.js","media/css/jquery.dataTables.css" ]
@H_404_5@有一个完整的讨论,关于为什么它像here.
(无耻插头)
我创建了一个bower-webpack-plugin,你可能想看一下.它仍处于开发阶段,但应该在主要领域处理数组.此外,如果您发现任何问题,请随时报告错误,我会尝试解决它.