FEATURE MISSING (this function is working with file-loader) Asset modules is only working with relative paths
See original GitHub issueI have an output that is not in the /
path, but instead, it is in /prod/webpack/
.
So the output is there.
The problem:
output: {
path: buildDir,
filename: '[name].[contenthash].js',
// chunkFilename: '[name].[contenthash].js',
// publicPath: '{{ app.url_subdir }}/webpack/',
publicPath: `prod/webpack/`,
assetModuleFilename: `assets/[hash][ext]`,
},
So, if everything for the assets is relative generating paths it generates a css like this:
@font-face {
font-family: 'Font Awesome 5 Brands';
font-style: normal;
font-weight: 400;
font-display: block;
src: url(prod/webpack/assets/89a52ae1d02b86d61439.eot);
src: url(prod/webpack/assets/89a52ae1d02b86d61439.eot?#iefix) format("embedded-opentype"), url(prod/webpack/assets/c1210e5ebe4344da5083.woff2) format("woff2"), url(prod/webpack/assets/329a95a9172fdb2cccb4.woff) format("woff"), url(prod/webpack/assets/9e138496e8f1719c6ebf.ttf) format("truetype"), url(prod/webpack/assets/216edb96b562c79adc09.svg#fontawesome) format("svg");
}
So it generates the url: prod/webpack/assets/89a52ae1d02b86d61439.eot
But given the CSS is already under a public path: prod/webpack/bundle.13123891f123.css
it tries to load a path like this: /prod/webpack/prod/webpack/assets/ada6e6df937f7e5e8b79.woff2
Before i could only fix it with file-loader useRelativePath: false
, but in asset modules it has no option to use absolute, and it is not working, it generates false paths.
Issue Analytics
- State:
- Created 2 years ago
- Comments:22 (10 by maintainers)
Top Results From Across the Web
webpack 5 file-loader is deprecated, how we can solve this ...
FEATURE MISSING (this function is working with file-loader) Asset modules is only working with relative paths webpack/webpack#13796.
Read more >Webpack 5 - Asset Module - Missing feature of url-loader
I wanted to switch to the webpack 5 asset module as recommended. Unfortunately I miss the function "postTransformPublicPath: (path: any) ...
Read more >Static Asset Handling - Vite
Importing a static asset will return the resolved public URL when it is served: ... public paths (based on project root during dev)...
Read more >Asset Modules - webpack
assetModuleFilename and works only with asset and asset/resource module types. Inlining assets. webpack.config.js const path = require('path'); module.exports = ...
Read more >Webpack — Understanding the 'publicPath' mystery - Medium
So, this would work fine. But when we change it our actual path i.e. resolve('dist') , the webpack is still compiling and generating...
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
new URL('./path/to/script.js', import.meta.url)
syntax, if you need URL of JS filewebpack 5 simplify many things so you don’t need many options now, it will just work out of box