Skip to content

sourcemap paths are incorrect and doubled on webpack4 with [email protected] #203

@ocoka

Description

@ocoka

Hello, I found that on webpack4 with [email protected], and next config:

module.exports = {
  devtool: 'module-source-map',
  module: {
    rules: [
      {
        test: /\.styl(us)?$/,
        use: [
          {
            loader: 'css-loader',
            options: {
              sourceMap: true
            }
          },
          {
            loader: 'stylus-loader',
            options: {
              sourceMap: true
            }
          }
        ]
      }
    ]
  }
};

there is a problem with generated paths in sourcemap for stylus files, for example, with dir structure like this:
image
and index.js

import st from './assets/styles/main.styl';

I get this paths
'/home/ocoka/Documents/proj/test/src/assets/styles/ src/assets/styles/ buttons/buttons.styl',
'/home/ocoka/Documents/proj/test/src/assets/styles/main.styl'

some double path bug !!!

actually I have a repo to reproduce that

It's worh to mention that above bug I got with devtool: "source-map" parameter, maybe with variants like eval- it will not be such buggy, but I think that "source-map" more appropriate for present time, since it more clearer for Chrome Dev Tools with all it's current features

I've experimented a little, and will make a PR for you to consider proposed solution, of course it is not perfect, event maybe ugly )), but I don't have a strong knowledge about sourcemap machinery in general and have no experience in webpack world

Also I've found some discussion about new sourcemap behavior present in PR to css-loader:
webpack-contrib/css-loader#753, maybe you would be interested

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions