关于vue打包的问题
生活随笔
收集整理的這篇文章主要介紹了
关于vue打包的问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、vue-cli2
二、vue-cli3
一、vue-cli2
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hewelry@1.0.0 build: node build/build.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hewelry@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\techsun\AppData\Roaming\npm-cache\_logs\2019-09-20T06_38_09_597Z-debug.log
完整錯誤信息:
因為這個提示,找了一整天,結果是因為 標簽沒有閉合!!!,簡直巨坑。
2. 關于圖片資源路徑
(1)現將 route.js 中的 mode:history 改成 mode:hash
(2) config 文件夾下的 index.js
3. 改了 assetsPublicPath 還是加載不出來,或者 index.html 不顯示, 仍然報:Failed to load resource: net::ERR_FILE_NOT_FOUND。找到 build 文件夾
參考了這位老哥的分享:huang_jin_yi
(1)webpack.base.conf.js 文件
(2)webpack.prod.conf.js 文件添加:publicPath:'./
4. 圖片路徑正確,但是背景圖沒有
參考了這位老哥的分享:小嘜的前端寶庫
build文件夾下 utils.js 文件下添加:publicPath:"../../"
一、vue-cli3
1. router.js 文件–>將 history 模式改成 hash 模式
const router = new VueRouter({// mode: 'history',mode: 'hash',base: process.env.BASE_URL,//根routes })2. 在項目根目錄下 新增一個 vue.config.js 文件
module.exports = {publicPath : './',//打包時配置靜態資源路徑 打包要“./”// publicPath: '/tcEnterprise'// vue-cli3中baseUrl被廢棄,用publicPathoutputDir: 'tcTrace' // 打包后壓縮包的名稱 }3. npm run build
總結
以上是生活随笔為你收集整理的关于vue打包的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 清空表单时出现问题
- 下一篇: 创建vue项目(一)搭建vue-cli、