Possible to have image paths resolved using webpack's resolve.alias?
See original GitHub issueIt doesn’t look like this is currently supported by the loader, but please correct me if I’m wrong!
In my webpack.config.js
resolve: {
alias: {
// Allow friendly reference to core modules
"core": path.resolve(config.root, "../core")
}
},
https://webpack.github.io/docs/configuration.html#resolve-alias
I’m aliasing core
to a path, so I can have shorter friendlier paths to the core
across my application, this works fine in my js
files.
As it stands my images still need relative paths, to reference common assets in the core
:
<img src="../../../core/symbols/image.svg">
If the resolve.alias
were factored into path resolving, this could been simplified to:
<img src="core/symbols/image.svg">
Would this be possible?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Resolve | webpack
When enabled, symlinked resources are resolved to their real path, not their symlinked location. Note that this may cause module resolution to fail...
Read more >How to Create a Path Alias in Webpack - Bitovi
Open your Webpack.config.js file. · If it's not already there, add a resolve property to the configuration object and make it an empty...
Read more >Webpack resolve.alias does not work with typescript?
This solved my problem: we were using a custom module syntax which defined aliases to files other than index . Renaming the files...
Read more >Folder aliases using webpack • Today I Learned - Graffino
If the location of any of the folders defined with aliases ever changes, you no longer need to update all the imports -...
Read more >Webpack Aliases Keep My Code Sane - DEV Community
How to resolve relative paths cleanly in JavaScript and TypeScript by using webpack aliases. Tagged with javascript, webpack, typescript, ...
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 FreeTop 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
Top GitHub Comments
Have you tried using the
~
character in your paths to respect aliases? ie:This works for us. We’re using Webpack 2.
@dmackerman Didn’t work for me in the
.js
file, worked in.scss
file