R
R
Rafrey2018-06-23 16:27:12
React
Rafrey, 2018-06-23 16:27:12

React image path breaking?

I use facebook/create-react-app , but when I run npm run build , in the build folder, when opening index.html, css and js were not found immediately: /C:/static/css/main.27366ef3.css:1 Failed to load resource : writes such a path.
If you delete in Index.html / before the static , then the js and css themselves become visible, but then there are no pictures, during development all the ways worked. I import as indicated in the documentation, I did not find the answer to my question in more than 1 English-language source. also in the webpack documentation itself, who came across?

import React from 'react';
import logo from './logo.png'; /

function Header() {
  // Import result is the URL of your image
  return <img src={logo} alt="Logo" />;
}
export default Header;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rafrey, 2018-06-23
@Rafrey

if anyone encounters
add "homepage": ".", to your package json
https://github.com/facebook/create-react-app/issue...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question