Skip to content

inconsistent paths after render in imports on windows and linux #3516

Open
@alexander-akait

Description

@alexander-akait

In less-loader we have custom FileManager plugin (https://github.com/webpack-contrib/less-loader/blob/master/src/utils.js#L27).

Algorithm (https://github.com/webpack-contrib/less-loader/blob/master/src/utils.js#L87):

  • try to load less file using built-in FileManager, if it is fail
  • try to load less file using webpack resolver

We have a code:

@import '~bootstrap-less-port/less/bootstrap.less'; // means load from `node_modules`

So less failed to resolve, and webpack resolver return C:\path\to\projects\node_modules\bootstrap-less-port\less\bootstrap.less

No problems on this step. Compilation works fine.

After render (https://github.com/webpack-contrib/less-loader/blob/master/src/index.js#L38), we adding all resolved files to watcher (for recompilation them after change). But imports on windows contains forward slashes:

[ 
  'C:/Users/IEUser/test-webpack-watch/node_modules/bootstrap-less-port/less/bootstrap.less',
  'C:\\Users\\IEUser\\test-webpack-watch\\node_modules\\bootstrap-less-port\\less\\_functions.less',
  // ...
]

On linux and macos no problems:

[
   '/home/evilebottnawi/IdeaProjects/test-webpack-watch/node_modules/bootstrap-less-port/less/bootstrap.less',
  '/home/evilebottnawi/IdeaProjects/test-webpack-watch/node_modules/bootstrap-less-port/less/_functions.less',
  // ...
]

If we change source code to:

@import '../node_modules/bootstrap-less-port/less/bootstrap.less';

We don't have this problem.

Ref: webpack-contrib/less-loader#357

Reproducible repo:

https://github.com/Kukkimonsuta/test-webpack-watch

Just add console.log here https://github.com/webpack-contrib/less-loader/blob/master/src/index.js#L38

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions