bholloway / resolve-url-loader

Webpack loader that resolves relative paths in url() statements based on the original source file
563 stars 71 forks source link

Join Option Error #154

Closed dwhiting10 closed 3 years ago

dwhiting10 commented 4 years ago

I am trying to set up some custom processing of URLs using the join option. I am probably missing something obvious, but just doing a simple test like:

{ loader: "resolve-url-loader", options: { sourceMap: true, join: function(uri, base) { return 'test-url'; }, debug: true, } }

Returns an error "Module build failed (from ./node_modules/resolve-url-loader/index.js): Error: resolve-url-loader: CSS error join is not a function" Any help would be appreciated.

quentin-dietz commented 4 years ago

I ran into the same issue, and managed to fix it using the following config:

{
    loader: 'resolve-url-loader',
    options: {
      root: '',
      join: (a,b) => {return (c,d) => {
        return `./${c}`
      }}
      }
  },

Essentially the join function should return a function, and that seems to work.

bholloway commented 3 years ago

Thanks @quentin-dietz 🙏 . Closing as solved.

I will improve the docs in the next release.