我正在尝试使用babel / webpack转换js文件。由于某种原因,生成的文件缺少许多功能。我以前没有遇到过其他已编译文件的问题。在这段代码中,filterAddOns函数不包含在结果文件中,但populatePopUp包含在其中。
function filterAddOns(env) {
visibleAddOns = [];
popupAddOns = [];
originalAddOns.forEach((a) => {
....
});
}
function populatePopUp(addOns, id) {
var ppa = "";
addOns.forEach((x) => {
.....
});
$("#dvPopUpAddOns").html(ppa);
}
这是我的webpack文件。知道为什么它会跳过某些功能而不是其他功能吗?
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
ecma: undefined,
warnings: false,
parse: {},
compress: {},
mangle: true, // Note `mangle.properties` is `false` by default.
module: false,
output: null,
toplevel: false,
nameCache: null,
ie8: false,
keep_classnames: undefined,
keep_fnames: true,
safari10: false,
},
}),
],
},
entry: {
translate: ["@babel/polyfill", "./Scripts/es6/translate.js"],
onlineQuote: ["./Scripts/es6/quote/onlineQuote.js"]
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, './Scripts/build'),
},
module: {
rules: [{
loader: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/
}]
}
}