Skip to content
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
This repository was archived by the owner on Aug 28, 2026. It is now read-only.

Can't Live Edit CSS/SCSS Sources in Chrome Workspaces without file:// #717

Closed

Description

@niedfelj

Do you want to request a feature or report a bug?

FEATURE

What is the current behavior?
Sourcemap from sub module css (from sass-loader) is stringified with absolute paths

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?
Would be great to be able to use Chrome 66 workspaces to live edit files, but Chrome requires that sourceMap has file:// at the beginning

If this is a feature request, what is motivation or use case for changing the behavior?
To use Chrome workspaces to live edit scss/css

Please mention other relevant information such as your webpack version, Node.js version and Operating System.
webpack 4.8.3
node 8.10.0
MacOS 10.13.4

I was able to get the correct behaviour by doing the following on lines 117..132 in loader.js

		var moduleJs;
		if(sourceMap && result.map) {
			// add a SourceMap
			map = result.map;
			if(map.sources) {
				map.sources = map.sources.map(function(source) {
					return "file://"+source.split("!").pop().replace(/\\/g, '/');
				}, this);
				map.sourceRoot = "";
			}
			map.file = map.file.split("!").pop().replace(/\\/g, '/');
			map = JSON.stringify(map);
			moduleJs = "exports.push([module.id, " + cssAsString + ", \"\", " + map + "]);";
		} else {
			moduleJs = "exports.push([module.id, " + cssAsString + ", \"\"]);";
		}

Does it make sense to set this as an option or use another webpack default, for example in the output I'm also using

    output: {
      devtoolModuleFilenameTemplate(info) {
        const newPath =  'file://' + path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')
        return newPath
      },
    },

Activity

  1. alexander-akait commented on May 18, 2018

    @alexander-akait
    Member

    @niedfelj seems you have invalid configuration webpack out of box work with workspaces

  2. niedfelj commented on May 18, 2018

    @niedfelj
    Author

    @evilebottnawi What should it be? I'm working with the new Shopify slate/slate-tools project. Opened this ticket with them also

    Shopify/slate#447

  3. niedfelj commented on May 18, 2018

    @niedfelj
    Author

    Also reference this issue webpack/webpack#6400

  4. alexander-akait commented on May 18, 2018

    @alexander-akait
    Member

    Looks like we can close this issue in favor webpack/webpack#6400

  5. niedfelj commented on May 18, 2018

    @niedfelj
    Author

    @evilebottnawi While they are related, they are not the same issue. css-loader is responsible for munging these sourceMaps, there is nothing webpack or that issue can do to resolve it by itself.

  6. alexander-akait commented on May 18, 2018

    @alexander-akait
    Member

    @niedfelj how you imagine we will fix it in css-loader?

  7. niedfelj commented on May 18, 2018

    @niedfelj
    Author

    I guess with an option like sourceMapUrlPrefix or a similar callback function as mentioned above with devtoolModuleFilenameTemplate(info) (or maybe look for that output setting and use the same so they output the same file formats?

  8. alexander-akait commented on May 18, 2018

    @alexander-akait
    Member

    @niedfelj we should first solve this in webpack, maybe add new api, which allow us using this, no new option(s)

  9. niedfelj commented on May 18, 2018

    @niedfelj
    Author
  10. alexander-akait commented on May 18, 2018

    @alexander-akait
    Member
  11. HairyRabbit commented on Jul 8, 2018

    @HairyRabbit

    :)

    Anything update here?

    image

    Happen when I chain loader by 'postcss-loader'

    use: [
      'style-loader?sourceMap',
      'css-loader?sourceMap',
      'postcss-loader?sourceMap'
    ]

    Fix sources path and prepend file:/// looks fine for me:

    2

  12. added this to the 2.1.0 milestone on Aug 8, 2018
  13. modified the milestones: 2.1.0, 2.2.0 on Mar 5, 2019
  14. alexander-akait commented on Mar 11, 2019

    @alexander-akait
    Member

    @HairyRabbit your problem already solved in last release and not related to top issue

  15. alexander-akait commented on Mar 11, 2019

    @alexander-akait
    Member

    Close in favor #622 (comment)

    Anyway you can setup editing in dev tools:

    1. Open dev tools.
    2. Click Filesystem in on left panel.
    3. Click Add folder to workspace in left panel.
    4. Add src/lib directory.
    5. Change content of file.

    Anyway we should respect devtoolModuleFilenameTemplate and other devtool options, close in favor #622 (comment). Thanks for issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions