我正在尝试捆绑moment.js,但捆绑后它一直未定义:
var path = require("path");
var webpack = require("webpack");
module.exports = {
mode: "development",
entry: {
frb: "./src/app/loader.js"
},
output: {
path: path.resolve(__dirname, "./src/lib"),
filename: "bundle.js"
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules)/,
loader: "babel-loader",
query: {
presets: [
[
"@babel/preset-env",
{
targets: {
chrome: "58",
ie: "9"
}
}
]
]
}
}
]
},
plugins: [
// Ignore all locale files of moment.js
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.ProvidePlugin({
moment: "moment"
})
]
};
我的loader.js只是:
require("moment")