Vue cli project, what is the problem with the picture path after build?

1. Build the project using vue init webpack-simple, and the directory structure is as follows

2.

introduces the image
3 in the components of vue. After the project is deployed, because the project is placed under the domain name http. Com / static, the path of the image is wrong. How to solve it?

Mar.17,2021

assetsPublicPath:'. /'


assetsPublicPath:'. /'

utils.js

if (options.extract) {
      return ExtractTextPlugin.extract({
        use: loaders,
        fallback: 'vue-style-loader',
        publicPath:'../../'
      })
    } else {
      return ['vue-style-loader'].concat(loaders)
    }

webpack.base.conf

{
   test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
   loader: 'url-loader',
   options: {
     limit: 10000,
     name: utils.assetsPath('img/[name].[hash:7].[ext]'),
     outputPath: process.env.NODE_ENV === 'production' ? '../' : ''
  }
},

you can see how to configure web pack to physically disappear the picture, and packaging it into bace64 can also reduce the number of connections.

Menu