我正在使用加载程序使用webpack和本地映像,并且一切正常,但是使用Mocha运行测试时出现问题,出现以下错误。任何帮助,将不胜感激。
SyntaxError:意外字符'�'(1:0)
1 | PNG | ^ 2 | 3 | npm ERR!测试失败。有关更多详细信息,请参见上文。
这是我的webpack.config.js。
const path = require('path')
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'public/scripts'),
filename: 'bundle.js',
publicPath: '/scripts/'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
},
{
test: /\.(png|jpg)$/,
loader: 'url-loader?limit=8192'
}
]
},
devServer: {
contentBase: path.resolve(__dirname, 'public'),
publicPath: '/scripts/'
},
devtool: 'source-map'
}
来自package.json
"test": "mocha --compilers js:babel-core/register"
"devDependencies": {
"file-loader": "^2.0.0",
"url-loader": "^1.1.1"
}