I try to integrate my own local images in my theme using the following import in my header: import mylogo from './../assets/images/logo.jpg';
but the compilation process hangs, even if I just import the file without displaying my logo.
Latest message during compilation:
SERVER STARTED -- Listening @ http://localhost:3000
- mode: development
- target: module
The process consumes almost 100% of CPU, I could assume that it comes from webpack, but can’t figure out how to solve that issue. Importing CSS files works fine, but this issue happens when importing jpg or png files.
Step to reproduce:
Add a valid logo.png file in src/assets/images folder in local mars theme
Add import mylogo from './../assets/images/logo.jpg'; line to header.js in mars-theme
Run npx frontity dev
Am I missing something here? I’m using Win 10, not using any additional packages or whatever, just doing the steps described above.
Hello @cobra, can you share the code where you are using the logo after import. For reference i am using the following code and the image is working perfectly.
Yes, now I’ve copied the code you’ve used and am still having the same problem.
import React from "react";
import { connect } from "frontity";
import LogoPath from "../assets/logo.jpg";
const Header = ({ state }) => (
<>
<Container>
<LogoContainer>
<Logo src={LogoPath} />
</LogoContainer>
</Container>
</>
);
export default connect(Header);
So, I’ll try the same with my mac again tomorrow and let you know the result. I have the feeling it has something to do with the os. I’ve updated Node to 10.16.3 and npm to 6.9.0 now, no difference…
I guess that happens because of the backslashes in filenames.
It gives me the whole filename, instead of cutting it off like on Mac OS where the whole thing is working. C:\Users\cobra\Documents\app\packages\mars-theme\src\assets\images\logo.jpg
For now, I will use the customized regex const filename = /([\w-]+)\.(?:png|jpe?g|gif|svg)$/.exec(file) || [, "image"];
Could that be an official solution in the upcoming release? I’m not a regex expert
Don’t know why webpack stucks and doesn’t give any errors, but I assume it happens because of illegal path characters in the file name on Windows.
The same problem occurs today in Mac OS. I have added a logotype, both tested in a Static folder and in assets folder under src. The logo turns up once, but after update there is a problem with webpack.
I have this code: