2016-04-12 30 views
0

Webpack kullanarak html dosyasını küçültmek için html-webpack-plugin kullanıyorum.html-webpack-plugin gereksiz etiketler üretir

Orijinal html dosyasının yalnızca <script src="./app.js"></script> vardır, ancak html-webpack-plugin kullanarak dosyayı küçültdükten sonra <script src="./app.js"></script><script src="app.js"></script> üretir. Bir yedekli <script src="app.js"></script> ekler. html-minifier'un sunduğu her seçeneği denedim, ancak sorunu çözmedim.

Bunu nasıl çözeceğini bilen var mı? Benim webpack config

kısmı:

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

Dokümanlar 'eklenti script tags' kullanarak vücuttaki tüm webpack demetleri yer alacağı bir HTML5 dosyası oluşturur. Böylece, şablondan '' öğesini kaldırabilirsiniz. –

+0

Çok teşekkür ederim !!!! Bu problemi çözdü. – tet

cevap

0

eklenti bir seçenek yoktur. Bunu yanlış olarak ayarlayabilir ve kendiniz yazabilirsiniz ya da bunu doğruya vb. Ayarlayabilirsiniz ve satırlarınızı html'den kaldırabilirsiniz. Daha fazla bilgi için

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

:

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