Reputation: 7316
When I use create-react-app's %PUBLIC_URL%
token in my root html file, WebStorm complains that it can't resolve the url it is part of.
The error is: Cannot resolve directory '%PUBLIC_URL'
In this case the warning is spurious: it works as intended in development and production. The %PUBLIC_URL%
token maps to the location of the public/
directory, which I have marked as the resource root.
I can suppress the warning for the entire file with a <!--suppress HtmlUnknownTarget -->
directive, but that means WebStorm won't check that urls are valid. This comment also appears in the final html output, which is sort of undesirable too.
Can I get WebStorm to understand what %PUBLIC_URL%
means in the context of a create-react-app instance?
Upvotes: 5
Views: 1036
Reputation: 1464
It's not really a perfect solution but you can create a symbolic link in your project root called %PUBLIC_URL%
that points to the public
directory.
On Linux:
ln -s public/ %PUBLIC_URL%
On Windows (I have not tested this so it may not work):
mklink /D %PUBLIC_URL% public
Upvotes: 3