kevin1024/django-npm

Path separators should be translated on Windows

Opened this issue · 2 comments

On Windows, NPM_FILE_PATTERNS only works if you use backslash separators like so:

NPM_FILE_PATTERNS = {
    "bootstrap": [
        "dist\\css\\bootstrap.min.css",
        "dist\\css\\bootstrap.min.css.map",
        "dist\\js\\bootstrap.bundle.min.js",
        "dist\\js\\bootstrap.bundle.min.js.map",
    ],
}

This is problematic when you want to write portable code.
We should be able to use forward slash on all operating systems.

Let me know if you want me to open a Pull Request.

I believe this bug is already fixed by #18.

Nope, I just checked with the master branch, and the problem is still there.

Interestingly, you can work around this issue by using Paths instead of strings:

NPM_FILE_PATTERNS = {
    "bootstrap": [
        Path("dist/css/bootstrap.min.css"),
        Path("dist/css/bootstrap.min.css.map"),
        Path("dist/js/bootstrap.bundle.min.js"),
        Path("dist/js/bootstrap.bundle.min.js.map"),
    ],
}