this error is occuring in my react application.
the full message says ./bluecardback.jpg 1:0 Module parse failed: Unexpected character '�' (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file)
webpack.config:
var webpack = require('webpack');
var path = require('path');
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry: [
path.join(__dirname, './src/index.js')
],
module: {
rules: [{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: [{ loader: 'babel-loader', options: { presets: ['@babel/preset-env', '@babel/react'] } }],
},
{
test: /\.(less|css|scss)$/,
use: ['style-loader', 'css-loader', 'less-loader',]
}
]
},
output: {
path: path.join(__dirname, '/public'),
filename: 'bundle.js'
},
devServer: {
contentBase: path.join(__dirname, '/public'),
// historyApiFallback: true
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.html"
})
]
}
package.json:
{
"name": "react-client",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.9.0",
"react-dnd": "^14.0.3",
"react-dnd-html5-backend": "^14.0.1",
"react-dom": "^16.9.0",
"react-scripts": "^4.0.3",
"socket.io-client": "^2.2.0"
},
"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.6",
"babel-register": "^6.26.0",
"css-loader": "^3.6.0",
"file-loader": "^4.3.0",
"html-webpack-plugin": "^3.2.0",
"less": "^3.10.3",
"less-loader": "^5.0.0",
"style-loader": "^1.3.0",
"url-loader": "^2.3.0",
"webpack": "^4.39.3",
"webpack-cli": "^3.3.7",
"webpack-dev-server": "^3.8.0"
},
"scripts": {
"start": "webpack-dev-server --mode=development --port=4000 --inline --hot",
"build": "webpack --mode=production"
}
}
my import looks like this import background from "../bluecardback.jpg";
importis for importing components, which is code. You cannot import a.jpgfile. You're importing "background" from a jpg file; how is it possible to even define a background function in a JPG file?url(${background}),}}></div>