Skip to content
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

Can't find webpack.config.js on Windows #26

Open
RinkAttendant6 opened this issue Jul 8, 2017 · 1 comment
Open

Can't find webpack.config.js on Windows #26

RinkAttendant6 opened this issue Jul 8, 2017 · 1 comment

Comments

@RinkAttendant6
Copy link

The plugin doesn't seem to build the path correctly on Windows. The exact same code works fine on Linux.

.eslintrc.yaml

---
root: true
env:
    browser: true
    node: true
    es6: true
parserOptions:
    ecmaVersion: 8
    sourceType: module
plugins:
    - require-path-exists
extends:
    - eslint:recommended
    - plugin:require-path-exists/recommended
rules:
    require-path-exists/exists:
        - error
        -
            webpackConfigPath: webpack.config.js

webpack.config.js

module.exports = {
    resolve: {
        alias: {
            '@includes': require('path').resolve(__dirname, 'public', 'global', 'resources', 'js')
        }
    }
};

Error

grunt eslint gives me this output:

Warning: Error while loading rule 'require-path-exists/exists': Cannot load Webpack config: Cannot find module 'Z:GitHubProject1webpack.config.js' Use --force to continue.

@josejamart
Copy link

josejamart commented Feb 14, 2018

This is happening because when a windows path is used in a string, the backslashes have to be escaped. I have found a solution for that.

Add a check to escape backslashes only on windows.

In the file eslint-plugin-require-path-exists/src/exists.js in line 19 this lines have to be added.

if (process.platform === "win32") {
    pathname = pathname.replace(/\\/g, "\\\\");
  }

There will be also necessary to change pathname from const to let, because now we are going to modify that. The final code will be so:

  let pathname = path.resolve(fromDir);
  if (process.platform === "win32") {
    pathname = pathname.replace(/\\/g, "\\\\");
  }

  if (webpackConfigCache[pathname]) {
    return webpackConfigCache[pathname];
  }

I hope this solution, or other could be added as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants