I have a React component that’s being used in Next.js page:
/pages/index.js
JavaScript
x
12
12
1
import React from 'react';
2
import ReactDOM from 'react-dom';
3
import Layout from "../src/hoc/Layout/Layout";
4
import Main from "../src/components/Main/Main";
5
6
const Index = () => (
7
<Layout>
8
<Main />
9
</Layout>
10
);
11
export default Index
12
In Main.js I have the following code
JavaScript
1
2
1
import macbookIphone from '../../assets/images/mac-iphone.jpg';
2
I get the following error
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)
I tried doing the following
In next-config.js
JavaScript
1
3
1
const withImages = require('next-images')
2
module.exports = withImages()
3
I’m still getting the same error.
What am I doing wrong?
Advertisement
Answer
/public/favicon/mail.png
=> “/favicon/mail.png” will work