Webpack 为什么网页在每行之前都会输出奇怪的评论?

Webpack 为什么网页在每行之前都会输出奇怪的评论?,webpack,Webpack,网页包在输出中生成的前导/******/注释是什么?它是用来标记与网页包相关的代码,还是还有更多 下面是一个简单的输出示例: /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ // The require function /******/ function __webpac

网页包在输出中生成的前导/******/注释是什么?它是用来标记与网页包相关的代码,还是还有更多

下面是一个简单的输出示例:

/******/ (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) {

    document.write('I think it works!');


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

Webpack为您的模块和块提供标识以识别它们。为了最小化脚本,建议使用UglifyJs插件(
newwebpack.optimize.UglifyJsPlugin()


我建议您阅读该页面,在那里您可以找到有关如何最小化和进一步优化脚本的信息。

是的-它标记了与网页包相关的代码。我有点困惑,这样一个模糊的约定已经被接受。