'css-loader' can't resolve the relative path in production mode since 14.6.0
See original GitHub issueDescription of the bug / feature
‘css-loader’ can’t resolve the relative path in production mode.
Minimal reproducible example
- My frontend folder looks like this:
-resources
-frontend
-css
leaflet-map-styles.css
-img
map_layers_icon.png
- leaflet-map-styles.css
[class="leaflet-control-layers-toggle"] {
background-image: url('img/map_layers_icon.png') !important;
background-size: 26px 26px;
}
- GoogleMap.java
@CssImport(value = "./css/leaflet-map-styles.css", themeFor = "leaflet-map")
public class GoogleMap extends Div {...}
- addon: Leaflet4Vaadin
Expected behavior
No problem when running/building image
Actual behavior
ERROR in ../node_modules/@vaadin/flow-frontend/css/leaflet-map-styles.css
Module build failed (from ../node_modules/css-loader/dist/cjs.js):
Error: Can't resolve 'img/map_layers_icon.png' in 'D:\test\node_modules\@vaadin\flow-frontend\css'
at D:\test\node_modules\enhanced-resolve\lib\Resolver.js:209:21
at D:\test\node_modules\enhanced-resolve\lib\Resolver.js:285:5
...
@ ../target/frontend/generated-flow-imports-fallback.js 33:0-71 34:89-96
@ ../target/frontend/generated-flow-imports.js?babel-target=es6
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18:38 min
[INFO] Finished at: 2021-05-18T13:23:50+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:14.6.1:build-frontend (default) on project test: Webpack process exited with non-zero exit code.
[ERROR] Stderr: ''
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.vaadin:vaadin-maven-plugin:14.6.1:build-frontend (default) on project test: Webpack process exited with non-zero exit code.
Stderr: ''
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
...
Versions:
- Vaadin / Flow version: 14.6.1 (brokenness starts with 14.6.0)
- Java version: 11
- OS version: Windows 10
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
'css-loader' can't resolve the relative path in production mode since ...
'css-loader' can't resolve the relative path in production mode. Minimal reproducible example. My frontend folder looks like this: -resources -frontend -css ...
Read more >css-loader can not resolve urls generated by file-loader
So look like css-loader with turned on css-modules wants url paths as a node relative paths with ./ , not just as a...
Read more >webpack can't resolve 'path' | The AI Search Engine You Control
If you're just generating CSS without passing it to the css-loader , it must be relative to your web root. You will be...
Read more >css-loader | webpack - JS.ORG
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >API - ESBuild
External paths are applied both before and after path resolution, ... For example, the js loader interprets the file as JavaScript and the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The fix will come in 14.6.2
Closing issue as the fix has been merged and it should roll out sometime soon.
Until release of 14.6.2 you can in the mean while add the raw-loader dependency to a java class with
@NpmPackage(value = "raw-loader", version = "3.1.0")
and then adding towebpack.config.js
the linesThis ticket/PR has been released with platform 14.7.0.alpha3 and is also targeting the upcoming stable 14.7.0 version.