Cannot get this loader to work to support import.meta.url

I’m trying to load in a vue-cli 4 project and it’s giving me this error:

Failed to compile with 1 errors                                                                                                                              

error  in ./node_modules/chessboard-element/lib/chessboard-element.js

because of this line:

const wikipediaPiece = (p) => new URL(`../chesspieces/wikipedia/${p}.png`, import.meta.url).href;

After digging a bit, it seems to be because Webpack doesn’t support import.meta.url as described here:

There is a loader that is supposed to solve the problem here:


I installed it and then added this to me vue.config.js

  chainWebpack(config) {

Not getting any errors so the loader seems to load correctly, although it’s my first time trying to use a custom loader so I may be doing something wrong. In any case, the same error occurs and the loader seems to not be working

Help would be appreciated! Thanks!