我猜我的webpack在某种程度上并没有与babel作为加载器进行转换,我得到了例外,
我有babel-core,babel-presets-es2015,安装了babel-loader我配置了.babelrc文件,预设为es2015
我运行webpack.server,一切顺利然后我尝试运行build \ server它显示此异常 添加了我的webpack配置和依赖项 谢谢
var path = require("path");
function createConfig(isDebug) {
return {
target: "node",
devtool: "source-map",
entry: "./src/server/server.js",
output:{
path: path.join(__dirname, "build"),
filename: "server.js"
},
resolve: {
alias: {
shared: path.join(__dirname, "src", "shared")
}
},
module:{
loaders: [
{test: /\.js$/, loader: "babel-loader", exclude: /node_modules/ },
{test: /\.js$/, loader: "eslint-loader", exclude: /node_modules/ }
]
}
};
}
module.exports = createConfig(true);
module.exports.create = createConfig;
var path = require("path");
function createConfig(isDebug) {
return {
target: "node",
devtool: "source-map",
entry: "./src/server/server.js",
output:{
path: path.join(__dirname, "build"),
filename: "server.js"
},
resolve: {
alias: {
shared: path.join(__dirname, "src", "shared")
}
},
module:{
loaders: [
{test: /\.js$/, loader: "babel-loader", exclude: /node_modules/ },
{test: /\.js$/, loader: "eslint-loader", exclude: /node_modules/ }
]
}
};
}
module.exports = createConfig(true);
module.exports.create = createConfig;
答案 0 :(得分:0)
query:{presets:["es2015"]}
添加到 config ...
module:{
loaders: [{
test: /\.js$/,
loader: "babel-loader",
exclude: /node_modules/,
query:{
presets:["es2015"]
}
},
{
test: /\.js$/,
loader: "eslint-loader",
exclude: /node_modules/
}
]
}
...
祝你好运。