vue项目直接打开dist文件夹下面的index.html文件

关于vue项目直接点击dist文件夹下面的index.html文件使项目在浏览器显示,需配置两个文件,

config/index.js

build: {
    assetsPublicPath: './',
  }

build/utils.js

function generateLoaders (loader, loaderOptions) {
    const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]

    if (loader) {
      loaders.push({
        loader: loader + '-loader',
        options: Object.assign({}, loaderOptions, {
          sourceMap: options.sourceMap
        })
      })
    }

    // Extract CSS when that option is specified
    // (which is the case during production build)
    if (options.extract) {
      return ExtractTextPlugin.extract({
        use: loaders,
        fallback: 'vue-style-loader',
        publicPath:'../../',//这里更改css的路径这样图片就能正常显示
      })
    } else {
      return ['vue-style-loader'].concat(loaders)
    }
  }

 

    原文作者:Zxiuping
    原文地址: https://blog.csdn.net/Zxiuping/article/details/107831603
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞