2016-11-30 3 views
1

html-webpack-plugin 내 js 덩어리에만을 사용하고 싶습니다. Bundle.css 추출 텍스트 - 플러그인에 의해 생성됩니다html-webpack-plugin에서 생성 된 index.html에서 bundle.css를 제외하는 방법은 무엇입니까?

new ExtractTextPlugin({filename: 'bundle.css, allChunks: true}) 

HtmlWebpackPlugin 옵션 :

new HtmlWebpackPlugin({template: 'template/tpl.html', inject: true}) 

내 tpl.html은 다음과 같습니다

<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
 
    <title>Cash Management</title> 
 
    <link href="getResource?resource=build/bundle.css&mediaType=text/css" rel="stylesheet"> 
 
</head> 
 
<body> 
 
<div id='root' /> 
 
</body> 
 

 
</html>

나는 뭔가를보고 싶다. 내 index.html을이를 E :

<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
 
    <title>Cash Management</title> 
 
    <link href="getResource?moduleName=cm-ui&resource=build/bundle.css&mediaType=text/css" rel="stylesheet"> 
 
</head> 
 
<body> 
 
<div id='root' /> 
 
</body> 
 
    <script href="getResource?moduleName=cm-ui&resource=build/common.js" type="text/javascript"></script> 
 
    <script href="getResource?moduleName=cm-ui&resource=build/bundle.js" type="text/javascript"></script> 
 
</html>

은 누군가가 올바른 방향으로 날 지점시겠습니까?

+0

빠른 견해로 나는 'allCunks : true'키에 오자가 있음을 보았습니다. =>'allChunks : true' –

+0

고맙습니다. –

답변

1

당신은 당신이 자동으로 붙여되지 않도록 자산을 제외 할 수 있습니다 그것으로 html-webpack-exclude-assets-plugin

를 사용할 수 있습니다. 또한 lodash 구문을 사용하여 템플릿 경로를 삽입 할 수 있습니다.

<link href="getResource?resource=<%= htmlWebpackPlugin.files.css[0] %>&mediaType=text/css" rel="stylesheet"> 
+0

좋은 해결책처럼 보입니다! 고마워! –

관련 문제