前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >vue+element踩坑记-项目build打包以后入口文件显示空白的解决方案

vue+element踩坑记-项目build打包以后入口文件显示空白的解决方案

作者头像
何处锦绣不灰堆
发布2020-05-29 14:48:26
8980
发布2020-05-29 14:48:26
举报
文章被收录于专栏:农历七月廿一
现象描述

我在准备测试一个项目的时候,需要打包给后端使用, 我打完包以后发现,入口文件,也就是这个文件

dist
dist

该文件是直接打不开的,那么我之前是遇到过的,此类的问题,开始是认为是router.js里面的mode改变了导致的,也就是我们在配置路由的时候是可以直接将mode:history的,在路由文件里面,但是我改变以后发现还是不行的,后来百度了以后发现是因为其中有一个文件是不对的,需要我们在配置文件里面将一个文件的指向改变一下 也就是这里 。位置是config下的index.js文件

代码语言:javascript
复制
module.exports = {
  dev: {

    // Paths
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {},

    // Various Dev Server settings
    host: 'localhost', // can be overwritten by process.env.HOST
    port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    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: {
    // Template for index.html
    index: path.resolve(__dirname, '../dist/index.html'),

    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './',

    /**
     * Source Maps
     */

    productionSourceMap: true,
    // https://webpack.js.org/configuration/devtool/#production
    devtool: '#source-map',

    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],

    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  }
}

上面的build中,需要在assetsPublicPath后面的/前面加上. 就这么简单

我写的可能不那么的全面,我只是用这样的办法解决了,目前暂且认为是可以的,以后有大神的话,可以交流一下,毕竟我只是一个vue的小白。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/06/14 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 现象描述
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档