webpack-contrib / expose-loader

Expose Loader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not work on Windows 10 OS?

hjlld opened this issue · comments

commented

First here's my webpack.config.js:

        test: /assets\/lib\/babylon.js/,
        use: [
          {
            loader: 'expose-loader',
            query: 'BABYLON'
          }
        ]

Then I found a weird thing, with a totally same project and its code:

  • After building on Windows 10 OS, window.BABYLON is not defined.
  • But after building on Mac or Linux, window.BABYLON is OK.

@hjlld please create minimal reproducible test repo, thanks!

commented

@evilebottnawi sorry for my late reply. Try this repo:

https://github.com/hjlld/expose-example

  1. npm install
  2. npm run build
  3. run a http server , and open index.html in browser.
  4. Try it again on another OS (Windows 10 versus Linux / Mac), then you'll get it.

We just had the same problem.
On Windows apparently the file path comes with \ instead of /. So in your RegEx you should handle both cases as: /assets[\\\/]lib[\\\/]babylon\.js$/
(http://regexr.com/3geks)

commented

I assume this can be closed?
Given the loader can't do anything about how webpack handles the test-regexp, and the above mentioned regexp just doesnt match under windows? @d3viant0ne

Yep you're right, good catch @hjlld see @timse's comment