2016-10-06 4 views
1

私のプロジェクトで自分のコードを分割しているウェブパックの設定があります。私がしようとしているのは、チャンクを無視し、プロダクションビルドの場合は単一のファイルを生成することです。Webpackはプロダクションビルドのチャンクを無視します

これは私のWebPACKの設定ファイルである:これが原因で起こっているどのチャンクの私のindex.jsある https://gist.github.com/alyn000r/5663c1036ab8e60695ba4db4e866df5f

if (typeof require.ensure !== `function`) require.ensure = (d, c) => c(require); // mocha test runner polyfill 

/** 
* require.ensure allows asynchronous chunk loading of the component, which means an extra HTTP hop to download the component, 
* in exchange of smaller initial download footprint. 
* - Use require.ensure for components that are least frequently used 
* - Use require.ensure for components that import libraries that are large in size 
*/ 
export function lookup(componentName, callback) { 
    switch (componentName) { 
     // ============================== Components =============================== 
     case 'dD': 
      callback(require('./components/dD')); 
      break; 
     case 'eBL': 
      callback(require('./components/eBL')); 
      break; 
     case 'essay': 
      callback(require('./components/essay')); 
      break; 
     case 'hSM': 
      require.ensure([], require => callback(require('./components/hSM'))); 
      break; 

これは、その今を生成するものである:

enter image description here

(isProduction)がtrueの場合、1つのファイルを生成するのに役立ちます

isProductionの場合でもCommonChunks PluginとMinChunkSizePluginを削除しようとしましたが、チャンクはまだ発生しています。

は、私が行方不明です何を教えてください....私はまた

jsonpFunction: `jsonpFunction${jsonpPackageName}`, 
    chunkFilename: `${packageName}/${packageName}-[id].js`, 

を削除しようとしている。しかし、それはまだ0.0.js、1.1.js、2.2.jsを生成します。あなたがLimitChunkCountPluginで1チャンクの最大数を制限することにより、コード分割を無効にすることができますあなたに

答えて

0

ありがとう:

plugins: [ 
    new webpack.optimize.LimitChunkCountPlugin({ 
     maxChunks: 1 
    }); 
] 
+0

ねえ、この2つのファイルのCAS-コアrenderer.jsおよびCAS-コアrenderer-を生成し、 0.js maxChunks:0に設定しようとしましたが、5つのファイルが再度生成されたため、プラグインが無効になっていると思います。あなたの助けをありがとう! – alyn000r

関連する問題