Me and my colleague can reproduce this issue by following steps below:
- create a new react app using vite as bundler by running command
npm init vite@latest --template and choose react and typescript as scaffold;
- run
npm install react-material-web (at the moment its version is 1.0.5);
- using the library components in project;
- when run
npm run dev to start server, the error raised: Unable to resolve @import "~@fontsource/roboto" from xxx/node_modules/react-material-web/dist
A temporary solution would be removing the ~ symbol in the import statement at the 2nd line in /node_modules/react-material-web/dist/styles.css which means to turn
@import '~@fontsource/roboto';
into
@import '@fontsource/roboto';
After doing this little tweak it works.
I don't know if this is an issue related to vite bundler, but I think it's beneficial to first summit an issue here as it may affect some projects using vite.