2016-04-12 4 views
0

私はhtml-webpack-pluginを使用して、webpackを使用してhtmlファイルを縮小します。html-webpack-pluginは冗長タグを生成します

オリジナルのhtmlファイルは<script src="./app.js"></script>のみですが、html-webpack-pluginを使用してファイルを縮小した後は、<script src="./app.js"></script><script src="app.js"></script>が生成されます。 リダンダント<script src="app.js"></script>を挿入します。 私はhtml-minifierが提供するすべてのオプションを試しましたが、問題は解決していません。

誰もこれを解決する方法を知っていますか?私のWebPACKの設定の

一部:

new HtmlWebpackPlugin({ 
    template: 'app/main.html', 
    filename: 'index.html', 
    minify: { 
     collapseWhitespace: true, 
     removeComments: true, 
     removeRedundantAttributes: true, 
     removeScriptTypeAttributes: true, 
     removeStyleLinkTypeAttributes: true, 
    }, 
    }), 
+1

ドキュメント ':詳細については

inject: false // "body", "head" 

。したがって、テンプレートから ''を削除することができます。 –

+0

ありがとうございました!!!!それが問題を解決しました。 – tet

答えて

0

プラグインでのオプションがあります。これをfalseに設定して自分自身を書くことも、trueに設定してhtmlから行を削除することもできます。プラグインは、スクリプトtags`を使用して、本体にすべてのWebPACKのバンドルが含まれてあなたのためのHTML5ファイルを生成します

inject {Boolean|String} true true || 'head' || 'body' || false Inject all assets into the given template or templateContent. When passing true or 'body' all javascript resources will be placed at the bottom of the body element. 'head' will place the scripts in the head element