VUE-CLIプロジェクト共通の構成を知る必要があります

1、梱包後の設定ファイルのパス

>設定を入力すると、assetsPublicPath index.js: '/' の変更 'を./';

構築:{ 
  ENV:(必要 './prod.env' )、
  インデックス:path.resolve(__ dirnameは、 '../dist/index.html' )、
  assetsRoot:path.resolve(__ dirnameは、 '../dist' )、
  assetsSubDirectory: '静的' 
  assetsPublicPath: './' 
  productionSourceMap:
  productionGzip:
  productionGzipExtensions:[ 'JS'、 'CSS' ] 
  bundleAnalyzerReport:process.env.npm_config_report 
}

2、ポートの競合を防ぐために、9090にポート番号8080を変更

ポートを変更するには、config>のindex.jsを入力します:9090

module.exportsは= { 
  DEV:{ 
    assetsSubDirectory: '静的' 
    assetsPublicPath: ' / 
    ホスト: ''はlocalhost 
    ポート:9090、

3、クロスドメイン構成proxyTableは、開発環境で問題を解決します

= module.exportsは{ 
  DEV:{ 
    proxyTable:{
          '/ Dianping' :{ 
            対象: 'HTTP:// ****' 
            changeOrigin:trueに
            {:pathRewrite
               '^ / Dianping': '/ Dianping' // この自分のプロジェクトに応じてフィールドに記入
            } 
        } 
    }

4、いくつかの写真はビルド\に制限の失敗を参照するコメント制限をwebpack.prod.conf.js

{ 
  テスト: /\.(png|jpe?g|gif|svg)(\?.*)?$/ 
  ローダー: 'URL-ローダー'は
  オプション:{ 
    // 制限:10000、 
    名前:utils.assetsPath( 'IMG / [名] [ハッシュ:7]。[EXT]' 
  } 
}、

5、.MAPファイルのパッケージを削除しないでください

真の変更productionSourceMap:productionSourceMapのconfig \のindex.jsで偽

構築:{ 
  ENV:(必要 './prod.env' )、
  インデックス:path.resolve(__ dirnameは、 '../dist/index.html' )、
  assetsRoot:path.resolve(__ dirnameは、 '../dist' )、
  assetsSubDirectory: '静的' 
  assetsPublicPath: './' 
  productionSourceMap:
  productionGzip:
  productionGzipExtensions:[ 'JS'、 'CSS' ] 
  bundleAnalyzerReport:process.env.npm_config_report 
}

ビルドパッケージは絵の背景のCSSファイルにリリースされる後6、見つかりません。

以下のようにファイルが変更され、utils.jsファイルを見つけ構築:

    IF (options.extract){  
          返すExtractTextPlugin.extract({   
           ローダー、:使用   
           publicPathを: '../../'、// ビルドを解決することは、CSS BG IMG間違ったパスを読み込みます問題(この行が追加される) 
           フォールバック「VUEスタイルローダ」  
         })   
       } {  
          戻り [「VUEスタイルローダ」] .concat(ローダへ)   
       }   
     }

おすすめ

転載: www.cnblogs.com/mahmud/p/11518647.html