Webpack font file path problem

  1. webpack is configured as follows
 output: {
    path: path.resolve(__dirname, "../../public/static/dev"),
    filename: "js/[name].js"
    // filename: "js/[name]_[chunkhash:8].js"
  }, 
 module: {
    rules: [
     {
        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
        loader: "url-loader",
        options: {
          limit: 10000,
          name: utils.assetsPath("[name].[hash:7].[ext]")
        }
      }
    ]
}    

the util file is as follows

exports.assetsPath = function (_path) {
    const assetsSubDirectory = process.env.NODE_ENV === "production"
        ? "/public/static/dist/fonts/"
        : "/public/static/dev/fonts/"

    return path.posix.join(assetsSubDirectory, _path)
    //return assetsSubDirectory + _path;
}

as in the above code, the root directory of the website is the public directory, and the source code directory is the same as the public directory.
my font file is generated in xxx.com/public/static/dev/public/static/dev/fonts/,
and then the import file url of the font file in the web page is xxx.com/public/static/dev/fonts/.
the two are not unified, why does the directory generated by the font file change normally when I change the path of assetsPath in utils, but why does the path where the font file is introduced into the web page also change? How to unify the two file paths?
does not work with a relative path, because the relative path is under dev/html/ relative to the index.html, index.html directory.

Mar.05,2021
Menu