与babel-loader奇怪的源图工作

时间:2015-11-23 08:36:25

标签: webpack babeljs source-maps

我在webpack.config.js中有这段代码:

module.exports = {
   context: __dirname + '\\src',

   // The entry point for the bundle.
   entry: {
      home: './home'
   },

   // Options affecting the output.
   output: {
      path: __dirname + '\\public',
      // The filename of the entry chunk as relative path inside the output.path directory.
      filename: '[name].js'
   },

   devtool: 'source-map',

   // Options affecting the normal modules
   module: {

      // A array of automatically applied loaders.
      loaders: [
         {
            test: /\.js$/,
            exclude: /node_modules|gulp/,
            loader: 'babel-loader',
            query: {
               presets: ['es2015']
            }
         }
      ]

   },
};

home.js:

'use strict';

let a;

debugger;

console.log(a);

当我看到控制台时,我找到了

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

    'use strict';

    var a = undefined;

    debugger;

    console.log(a);

/***/ }
/******/ ]);
//# sourceMappingURL=home.js.map

而不是原来的home.js.这对我来说很奇怪,因为我使用了devtool:'source-map'。为什么会发生,我的错误在哪里?

0 个答案:

没有答案
相关问题