带有'stage-0'和'es2015'预设的Webpack babel-loader无法识别import语句

时间:2016-01-20 19:09:37

标签: webpack

使用config

module.exports = { context: __dirname + "/src", entry: "./main", output: { path: __dirname + "/dist", filename: "bundle.js" }, loaders: [ { test: /\.jsx?$/, exclude: /(node_modules|bower_components)/, loader: 'babel', // 'babel-loader' is also a legal name to reference query: { plugins: ['transform-runtime'], presets: ['react', 'stage-0', 'es2015'] } } ] }

(试图删除第0阶段)

我在src / main.js中遇到Line 8: Unexpected token ... You may need an appropriate loader to handle this file type.错误,其中第8行是评论后的第一行:

/*! @preserve * * The MIT License (MIT) * * * */ import t from './'

安装了预设,node_modules中的webpack版本为1.12.11

2 个答案:

答案 0 :(得分:0)

您没有指定要导入的模块。你刚刚提供了一个目录。

答案 1 :(得分:0)

您可以尝试更改stage-0es2015之间的顺序,如下所示:

presets: ['react', 'es2015', 'stage-0']