vue打包配置

TOC

vue打包配置

1.资源相对引用路径

  • build/webpack.prod.conf.js
找到output:增加 publicPath: './', 

1544748796358

2.背景图片的引用问题

  • build/utils.js
找到if (options.extract) {
添加一行  publicPath:'../../'

1544748888278

3.index.html页面没有显示内容

  • config/index.js
更改config/index.js 中的参数:
    assetsPublicPath:'./',

4.页面空白

  • router/index.js
将mode: 'history', /*使用HTML格式*/
注释掉(history需要另外配置才可以使用)

5.样式混乱

通用的css文件在main.js中统一引用,且放到最前面(不要在多个文件中引用,局部的在局部页面中引用即可)

1544754709082

6.降低打包文件大小

关闭 productionSourceMap

configindex.jsmodule.exportsbuildproductionSourceMap设置为false,打包的时候就不会生成map文件,打包速度也会提升很多;





原文地址:https://www.cnblogs.com/ziyue7575/p/393c6a20af6528f3602e2868984923ad.html