将CSS文件从Assets文件夹链接到Webpack html模板文件

时间:2018-11-09 05:46:15

标签: css webpack html-webpack-plugin

我有一个这样的模板html文件

b[3]

我想使用<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>aquaWeb</title> <link rel="stylesheet" type="text/css" href="???"> </head> <body> <div id="app"> <div class="some-placeholder"> I want to stylize this placeholder </div> </div> </body> </html> 中定义的规则来对占位符进行样式化。如何将那个CSS文件附加到此模板中?

1 个答案:

答案 0 :(得分:0)

您可以使用html-webpack-include-assets-plugin来将外部资产添加到html。

var HtmlWebpackIncludeAssetsPlugin = require('html-webpack-include-assets-plugin');

/// ...

plugins: [
  new HtmlWebpackPlugin(),
  new HtmlWebpackIncludeAssetsPlugin({ 
     assets: [
        'path/to/your/css/placeholder.css'
     ], 
     append: true })
]