-
-
Notifications
You must be signed in to change notification settings - Fork 469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generated image urls *must* be absolute for style!css?sourceMap to work? #55
Comments
yep. Do you want to add one in a PR? |
Same problem here. Bit of a confusing bug to run into. |
How to deal with HTTPS? Schema-less protocol does not work |
Same question for https |
I've figured out how to solve HTTPS issue. You can use your own dev server (take a look for |
Ah interesting. Thanks for sharing! I'll try that out. For now, I actually ended up going about it slightly differently. Since my main issue was being able to use |
@tizmagik is this how you resolved the disappearing images? was this in webpack.config.js? |
Yes, it seems to work fine even though using |
@tizmagik can you provide an example of working config, please? |
@tizmagik It will be helpful if you can provide a sample |
@creeperyang
|
@creeperyang sorry for the late reply, just saw this. @valerymercury yeap, that's basically what I have as well. Here's mine if it's any more helpful: const rootPublic = path.resolve('./public');
const LOCAL_IDENT_NAME = 'localIdentName=[name]_[local]_[hash:base64:5]';
const CSS_LOADER = `css?sourceMap&${LOCAL_IDENT_NAME}&root=${rootPublic}` + (DEBUG ? '&minimize' : '');
// ... loaders:
loaders: [
{
test: /\.css$/,
loader: DEBUG ? `style!${CSS_LOADER}` : ExtractTextPlugin.extract('style', CSS_LOADER)
}, // ...
] |
Has this been tested with relative pathed images (e.g. |
So unfortunately, this does not work when using CSS Modules, Has anyone been able to find another solution? |
Facing the same problem at the moment... |
Me too |
+1 |
Still not working for me with an absolute public path, e.g. |
meet the same question, just working for me with an absolute public path. |
|
…d svg file types This helps with css url() loading Still not correcting the url() + css-loader + source maps issues (webpack-contrib/style-loader#55)
just stumbled over this. if setting doesn't work: // your webpack config
{
devServer: {
publicPath: 'http://127.0.0.1:8888/'
// ... more devServer config
}
// ... more webpack config
} works for me: // your webpack config
{
output: {
publicPath: 'http://127.0.0.1:8888/'
// ... more webpack output config
}
devServer: {
// ... your devServer config
}
// ... more webpack config
} be sure to only set it in dev, who knows what this would do to your production build. good luck! |
@simshanith to make it work specify absolute {
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2|json|xml|ico)$/,
loader: 'file-loader',
query: {
outputPath: 'assets/',
publicPath: 'http://localhost:8080/', <- here
emitFile: true
}
} it will change URL in your CSS from relative to absolute |
Ok, so my issue wasn't related (I'll delete my comment if maintainers prefer), but in case someone does get here with the same problem as me, what fixes it for me was adding the: context option to file-loader (i'm actually using url-loader) with the base url that assets need to be loaded from. |
|
It seems with css sourceMaps enabled, even with publicPath set, styles (including bg images) are not applied. But what is odd is that I can see them in the inspector. If I turn the style off and on again then the style is applied. The below shows the page on initial load, showing a body background of paleturquoise in the dev console but the displayed background is white. repo here |
Is there a way to make images load in browser when using
style-loader/css-loader?sourceMap
without specifying absolute url prefix aspublicPath
?With this loader:
This works:
This doesn't:
In the CSS modules generated as
Blob
the paths are relative tochrome:blob
orchrome:devtools
which doesn't refer to the correct assets.If my assumption is correct and we always have to set absolute path in
output.publicPath
I will be happy to add a note about this to the docs.The text was updated successfully, but these errors were encountered: