question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

url() statement and source maps

See original GitHub issue

Hello,

I have read that in order to have source maps, I have to use absolute urls in the url('') statement. I did it this way :

body
    background-image: url('/elements/assets/tmp_background.jpg')

It works when I remove the sourceMap option from the css loader, it does not if I activate it.

I think I might have failed somewhere on the absolute path point, do you have any ideas?

Here is my config file :

module.exports = {
  devtool: 'source-map',
  entry: [
    'webpack/hot/dev-server',
    'webpack-dev-server/client?http://localhost:8080',
    path.resolve(__dirname, 'elements/main.js'),
  ],
  output: {
    path: 'dist',
    publicPath: '/',  // Prefix for all the statics urls
    filename: 'bundle.js',
  },
  resolve: {
    root: path.resolve(__dirname),
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader?presets[]=es2015',
      },
      { test: /\.css$/,  loaders: ['style', 'css'] },
      { test: /\.scss$/, loaders: ['style', 'css?sourceMap', 'sass?sourceMap'] },
      { test: /\.sass$/, loaders: ['style', 'css?sourceMap', 'sass?sourceMap&indentedSyntax=true'] },
      { test: /\.jade$/, loaders: ['ngtemplate', 'html', 'jade-html'] },
      { test: /\.(png|gif|jp(e)?g)$/, loader: 'url-loader?limit=8192' },
      { test: /\.(ttf|eot|svg|woff(2))(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=50000' },
    ],
  },
};

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:5
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
alexbeletskycommented, Jul 15, 2016

@jhnns sure, here you are:

https://github.com/blogfoster/webpack-sass-loader-issue

Please note, I’m not 100% sure that it’s sass-loader issue, could be related to some other dependent project. But repo clearly demonstrates it, try to open it with Chrome and Safari.

If you disable source-maps, it works correctly both browsers.

2reactions
timaschewcommented, Feb 13, 2016

For me the url breaks if I enable source maps. When I’m using the ExtractTextPlugin and enable source maps, there is just no source map available.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack sass loader with sourcemaps and url statements
I have read that in order to have source maps, I have to use absolute urls in the url('') statement. I did it...
Read more >
Should I Use Source Maps in Production? | CSS-Tricks
It's a valid question. A “source map” is a special file that connects a minified/uglified version of an asset (CSS or JavaScript) to...
Read more >
Anatomy of source maps | Bugsnag Blog
Source maps help you debug errors in your JavaScript code by mapping minified code to your original source. Learn how source maps work...
Read more >
SourceMap - HTTP - MDN Web Docs
The SourceMap HTTP response header links generated code to a source map, enabling the browser to reconstruct the original source and present ...
Read more >
What are JavaScript source maps? - Jim Fisher
The idiom seems to be to keep the map URL next to the JavaScript URL, e.g. the map for https://foo.com/scripts/main.js is typically hosted ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found