vue的config配置问题 以及 Refused to load the image 'http://localhost:8080/favicon.ico'

在文件夹config的index.js中配置dev和build

打包问题

  dev: {
    // Various Dev Server settings
    host: '127.0.0.1', // can be overwritten by process.env.HOST
    port: 80, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    // Paths
    assetsSubDirectory: 'static',
    // 相对 绝对路径问题
    assetsPublicPath: '/',
    // proxyTable: {},
    proxyTable: {
      '/api': {
        // 测试
        target: 'http://47.105.107.186:8889',
        // 最新的开发环境
        // target: 'http://192.168.1.156:8889',
        // target: 'http://47.104.71.52:8889',
        // secure: false,  // 如果是https接口,需要配置这个参数
        changeOrigin: true,
        pathRewrite: {
          '^/api': '', //地址重写,省略api 看的格式正确
        }
      },
    },
    autoOpenBrowser: false,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-

    /**
     * Source Maps
     */

    // https://webpack.js.org/configuration/devtool/#development
    devtool: 'cheap-module-eval-source-map',

    // If you have problems debugging vue-files in devtools,
    // set this to false - it *may* help
    // https://vue-loader.vuejs.org/en/options.html#cachebusting
    cacheBusting: true,

    cssSourceMap: true
  },
  build: {
    index: path.resolve(__dirname, '../dist/index.html'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './', //这行是改变的
}
原文地址:https://www.cnblogs.com/caoxueyang/p/13041807.html