DocSpring / craco-antd

A craco plugin to use Ant Design with create-react-app
MIT License
234 stars 49 forks source link

plugin breakes font imports build #26

Open NookieGrey opened 4 years ago

NookieGrey commented 4 years ago

After adding plugin getting such error, only in build, development works well

./src/assets/styles/index.less
ModuleNotFoundError: Module not found: Error: Can't resolve './font/Museo/Museo-300.eot' in 'C:\Users\gagul\WebstormProjects\vsbl\src\assets\styles'

assets/styles/index.less @import "./fonts/index.less";

assets/styles/fonts/index.less @import "./Museo.less";

assets/styles/fonts/Museo.less

@font-face {
    font-family: 'Museo';
    src: url('../../font/Museo/Museo-300.eot');
    src: url('../../font/Museo/Museo-300.eot?#iefix') format('embedded-opentype'),
    url('../../font/Museo/Museo-300.woff2') format('woff2'),
    url('../../font/Museo/Museo-300.woff') format('woff'),
    url('../../font/Museo/Museo-300.ttf')  format('truetype'),
    url('../../font/Museo/Museo-300.svg#Museo-300') format('svg');
}

all fonts are stored in assets/font

without plugin works great

NookieGrey commented 4 years ago

So this is min repro error https://github.com/NookieGrey/craco-antd-font try to build this app

alistairjcbrown commented 4 years ago

Looking at your repo linked above, you're using .less files in a Create React App build, which CRA doesn't support natively. Renaming them to .css solves the issue in your minimal repo, though I assume in your actual repository you're making use of Less styles?

Otherwise, looks like this may be related to an issue in the underlying craco-less plugin - https://github.com/DocSpring/craco-less/issues/38