Vue項目部署到服務器


打開項目的config--->index.js,改動如下兩處代碼

build: {
    // Template for index.html
    index: path.resolve(__dirname, '../dist/index.html'),
 
    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './',    // 1- 這里最初為'/'改為'./'
 
    /**
     * Source Maps
     */
 
    productionSourceMap: false,   // 2- 這里最初為true改為false
    // https://webpack.js.org/configuration/devtool/#production
    devtool: '#source-map',

改動完成之后執行

npm run build

出現dist文件夾

將dist文件夾放到服務器的根目錄下即可利用域名訪問(dist可根據項目自行修改名稱)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM