Building creates absolute path structure in dist for fonts only

Okay, I just found the culprit in the webpack.config.js the following lines:

 {
    test: /\.(ttf|otf|eot|woff2?|png|jpe?g|gif|svg|ico)$/,
    include: config.paths.assets,
    loader: 'url',
    options: {
      limit: 4096,
      name: `[path]${assetsFilenames}.[ext]`,
    },
  },

Here [path] added the unwanted absolute path, so I changed it to

  {
    test: /\.(ttf|otf|eot|woff2?)$/,
    include: config.paths.assets,
    loader: 'url',
    options: {
      limit: 4096,
      outputPath: 'fonts/',
      name: `${assetsFilenames}.[ext]`,
    },
  },
  {
    test: /\.(png|jpe?g|gif|svg|ico)$/,
    include: config.paths.assets,
    loader: 'url',
    options: {
      limit: 4096,
      name: `[path]${assetsFilenames}.[ext]`,
    },
  },
2 Likes