我在使用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')
}
}
};
Package.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"
}
答案 0 :(得分:1)
问题是我同时拥有一个入口文件和一个包含文件。删除包含行即可解决此问题。