【问题标题】:Can't include jQuery Datatables via webpack bower components不能通过 webpack bower 组件包含 jQuery 数据表
【发布时间】:2014-11-01 21:51:15
【问题描述】:
require('datatables'); does not work

我很难尝试将 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']
    }
};

【问题讨论】:

    标签: jquery jquery-datatables bower webpack


    【解决方案1】:

    问题在于DirectoryDescriptionFilePlugin 需要在main 字段中输入单个字符串,而数据表的bower.json 声明了一个数组:

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

    有一个完整的讨论,关于为什么会这样here

    (无耻的插头)

    我创建了一个bower-webpack-plugin,您可能想看看。它仍在开发中,但应该处理 main 字段中的数组。此外,如果您发现任何问题,请随时报告错误,我会尽力修复它。

    【讨论】:

    • 非常感谢您的回复!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-26
    • 1970-01-01
    • 2013-07-17
    • 2015-05-25
    • 2016-09-26
    相关资源
    最近更新 更多