0

我在使用 babel-loader 时遇到了一些问题,并且无法终生找出问题所在。看起来 babel-loader 根本没有在编译,我怀疑 babel-loader 甚至没有被使用。即使我删除了use:块中的所有内容,结果也是一样的。将debug: true标志添加到选项不会更改控制台中的输出。但是,排除/包含选项确实有效,因此我确信正在使用该配置。有谁知道可能是什么问题?

    var path = require('path');

module.exports = {
    mode: 'development',
    entry: './project/src/rovbasekart.js',
    output: {
        filename: 'rovbase.js',
        path: path.resolve(__dirname, './project/src/dist')
    },
    module: {
        rules: [{
            test: /\.js$/, 
            include: [path.resolve(__dirname, '/project/src/')],
            exclude: [/node_modules/, './project/src/dist', './project/src/lib'], // ignore all files in the node_modules folder
            use: {
                loader: 'babel-loader',
                options: {
                    presets: [['@babel/preset-env', { "targets": { "browsers": "ie 11"}}]],
                    babelrc: false
                }
            }
        }]
    },
    devtool: 'inline-module-source-map',
    resolve: {
        extensions: ['.js'],
        alias: {
            Rovbase: path.resolve('./project/src/'),
            Verktoylinje: path.resolve('./project/src/verktoylinje'),
            Verktoy: path.resolve('./project/src/verktoylinje/Verktoy'),
            Styles: path.resolve('./project/src/styles')
        }
    }   
};

包.json:

    "scripts": {
    "webpack": "webpack --mode development"
  },
  "dependencies": {
    "@babel/core": "^7.0.0-beta.56",
    "@babel/preset-env": "^7.0.0-beta.56",
    "babel-loader": "^8.0.0-beta.4",
    "ol": "^5.1.3",
    "proj4": "^2.4.4",
    "webpack": "^4.16.5"
  },
  "devDependencies": {
    "webpack-cli": "^3.1.0"
  }
4

1 回答 1

1

问题是我有一个入口文件和一个包含文件。删除包含行解决了这个问题。

于 2018-08-24T13:41:32.243 回答