My app has a dependency on another project containing a React SPA. When the app builds, all static resources are copied into build dir / jar with the following structure:
../
|- index.html
|- webroot
|- static
| |- static/css/2.f5b2e8f7.chunk.css
| |- static/js/2.50b282b9.chunk.js
|
|- favicon.ico
and therefore available via classpath.
Now, when I render the index.html
like so:
handlers {
get{
response.contentType 'text/html'
render getClass().getResource( '/index.html' ).text
}
}
I see the following errors in the logs:
.. ERROR r.e.i.DefaultDevelopmentErrorHandler - 404 client error for request to /static/favicon.ico
.. ERROR r.e.i.DefaultDevelopmentErrorHandler - 404 client error for request to /static/static/css/2.f5b2e8f7.chunk.css
How can I make all those /webroot/static/**
-> /static/static/**
files accessible?
I tried looking at ratpack-asset-pipeline
to accomplish what I need, but failed to find anything classpath-related.
In a sister app based on Micronaut
I defined the following piece of config to enable static resources:
micronaut:
server:
port: 8890
cors.enabled: true
router:
static-resources:
default:
enabled: true
mapping: /static/**
paths:
- "classpath:webroot"
What is Ratpack's counterpart for this?