代码配置是
{
test: /\.js$/,
exclude: /node_modules/,
// loader: 'babel-loader',
use: [{
loader: 'imports-loader?this=>window'
},{
loader: 'babel-loader',
} ]
},
报错原因
ERROR in ./src/index.js 4:0
Module parse failed: 'import' and 'export' may only appear at the top level (4:0)
File was processed with these loaders:
* ./node_modules/imports-loader/index.js
* ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| (function() {
|
> import _ from "lodash";
| import $ from "jquery";
| import fn from "./test.js";
如果把imports-loader这个loader去掉又可以了,我像会不会是loader的问题,但是imports-loader我已经下了几次了,还是这样,请老师指点一下吧