简体   繁体   English

无法通过Webpack Bower组件包含jQuery Datatables

[英]Can't include jQuery Datatables via webpack bower components

require('datatables'); does not work

I'm having a hard time trying to include jQuery-Datatables as a webpack module from bower, the current settings work with other bower components, here part of the webpack config file: 我很难尝试将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']
    }
};

The problem is that the DirectoryDescriptionFilePlugin expects a single string entry in the main field, and the bower.json of datatables declares an array: 问题在于DirectoryDescriptionFilePlugin期望在main字段中输入一个字符串,而datatables的bower.json声明一个数组:

"main": [
        "media/js/jquery.dataTables.js",
        "media/css/jquery.dataTables.css"
]

There is a whole discussion, about why it's like that here . 关于这里为什么会这样的整个讨论。

(shameless plug) (无耻的插头)

I have created a bower-webpack-plugin , that you may want to look at. 我创建了bower-webpack-plugin ,您可能想看看。 It is still under a development, but should handle arrays in main field. 它仍在开发中,但应该在main领域处理数组。 Additionally if you find any issues with it, please feel free to report a bug, and I'll try to get it fixed. 此外,如果您发现任何问题,请随时报告错误,我们将尝试修复它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM