Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将遗留jQuery插件与webpack捆绑_Javascript_Webpack - Fatal编程技术网

Javascript 如何将遗留jQuery插件与webpack捆绑

Javascript 如何将遗留jQuery插件与webpack捆绑,javascript,webpack,Javascript,Webpack,我正在尝试为我开发的web应用程序优化一些页面,第一件显而易见的事情是将js库捆绑在一起。然而,我无法实现这一点与网页。例如,我有一个Feed.html页面,该页面使用以下库(为简洁起见,请保持列表简短): 插件/select2/3.5.4/select2.min.js 插件/bootstrap-daterangepicker/2.0.11/moment.min.js 插件/bootstrap-daterangepicker/2.0.11/daterangepicker.js 我希望webp

我正在尝试为我开发的web应用程序优化一些页面,第一件显而易见的事情是将js库捆绑在一起。然而,我无法实现这一点与网页。例如,我有一个
Feed.html
页面,该页面使用以下库(为简洁起见,请保持列表简短):

  • 插件/select2/3.5.4/select2.min.js
  • 插件/bootstrap-daterangepicker/2.0.11/moment.min.js
  • 插件/bootstrap-daterangepicker/2.0.11/daterangepicker.js
我希望webpack创建一个包含这些文件的包,并将其命名为
Feed.js
,这样我就可以包含这个单独的js文件,而不是单独包含其中的每个文件

由于我们使用的大多数插件都是遗留插件,因此它们不遵守常见的JS/AMD/UMD模式,而是作为页面上的简单标签使用。根据这些信息,我找到了webpack的
脚本加载器
,但它似乎没有任何作用

Page/Feed.js webpack.config.js Bundles/Feed.js
webpack似乎只是将
页面/Feed.js
作为捆绑包中的字符串输出。如何实现文件的这种连接?

您是否解决过这个问题。我刚刚开始这段旅程,面临着同样的问题,在如何处理这一问题上经验有限
require("script!../plugins/select2/3.5.4/select2.min.js");
require("script!../plugins/bootstrap-daterangepicker/2.0.11/moment.js");
require("script!../plugins/bootstrap-daterangepicker/2.0.11/daterangepicker.js");
module.exports = {
    entry: {
        Feed: './Page/Feed.js'
    },
    output: {
        filename: '[name].js',
        path: './Bundles/'
    },
};
    /******/ (function(modules) { // webpackBootstrap
    /******/    // The module cache
    /******/    var installedModules = {};

    /******/    // The require function
    /******/    function __webpack_require__(moduleId) {

    /******/        // Check if module is in cache
    /******/        if(installedModules[moduleId])
    /******/            return installedModules[moduleId].exports;

    /******/        // Create a new module (and put it into the cache)
    /******/        var module = installedModules[moduleId] = {
    /******/            exports: {},
    /******/            id: moduleId,
    /******/            loaded: false
    /******/        };

    /******/        // Execute the module function
    /******/        modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

    /******/        // Flag the module as loaded
    /******/        module.loaded = true;

    /******/        // Return the exports of the module
    /******/        return module.exports;
    /******/    }


    /******/    // expose the modules object (__webpack_modules__)
    /******/    __webpack_require__.m = modules;

    /******/    // expose the module cache
    /******/    __webpack_require__.c = installedModules;

    /******/    // __webpack_public_path__
    /******/    __webpack_require__.p = "";

    /******/    // Load entry module and return exports
    /******/    return __webpack_require__(0);
    /******/ })
    /************************************************************************/
    /******/ ([
    /* 0 */
    /***/ function(module, exports, __webpack_require__) {

        __webpack_require__(1)(__webpack_require__(2))

    /***/ },
    /* 1 */
    /***/ function(module, exports) {

        /*
            MIT License http://www.opensource.org/licenses/mit-license.php
            Author Tobias Koppers @sokra
        */
        module.exports = function(src) {
            if (typeof execScript === "function")
                execScript(src);
            else
                eval.call(null, src);
        }

    /***/ },
    /* 2 */
    /***/ function(module, exports) {

        module.exports = "require(\"script!../plugins/select2/3.5.4/select2.min.js\");\r\nrequire(\"script!../plugins/bootstrap-daterangepicker/2.0.11/moment.js\");\r\nrequire(\"script!../plugins/bootstrap-daterangepicker/2.0.11/daterangepicker.js\");\r\n\r\n"

    /***/ }
    /******/ ]);