hilla
hilla copied to clipboard
Files are not served from the configured `publicPath` in webpack
Description of the bug
In webpack.generated.js the public path is configured as
output: {
filename: `${build}/vaadin-[name]-[contenthash].cache.js`,
path: mavenOutputFolderForFlowBundledFiles,
publicPath: 'VAADIN/',
},
Many plugins such as css-loader and file-loader uses the publicPath to decide where to put files that can be loaded by the browser. However, Vaadin does not serve these files so the loaders just fail to work.
Minimal reproducible example
https://github.com/Artur-/css-test
Expected behavior
A CSS file that includes an image as background: url(./smiley.jpg) should work
Actual behavior
The url is correctly rewritten to http://localhost:8080/VAADIN/7d75bb859852dba3f174ee59db92b2c2.jpg or similar and the file is correctly created in ./target/classes/META-INF/VAADIN/7d75bb859852dba3f174ee59db92b2c2.jpg (when in production mode) but the file is not served.
Versions:
- Vaadin / Flow version: 14
The problem is likely caused by that StaticFileServer.java explicitly filters for /VAADIN/build/ prefix.
Indeed, I worked around it as https://github.com/vaadin/flow/commit/78495fa56291bfe923f3aee60ac7205c1b8a8c0e but there is probably a reason that it is made the way it is, i.e. that files in VAADIN but outside build are not served
This is fixed in the feature/offline branch, we can backport to other Flow branches.