html-tag-replace-webpack-plugin

1.0.2 • Public • Published

html-tag-replace-webpack-plugin

���个�html-webpack-plugin���修���件������件�����添��css�js�����注��置����

��

npm install html-tag-replace-webpack-plugin

使�

html模�

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="keywords" content="" />
    <meta http-equiv="description" content="" />
    <title>html-replace-webpack-plugin demo</title>

    <!-- inject:css -->
    <!-- endinject -->
  </head>
  <body>

    <!-- inject:js -->
    <!-- endinject -->
  </body>
</html>

webpack.config.js

var HtmlTagReplaceWebpackPlugin = require('html-tag-replace-webpack-plugin')

module.exports = {
  ...
  plugins: [
    new HtmlTagReplaceWebpackPlugin({
      inject: true,
      injectPoint: {
          css: ['<!-- inject:css -->', '<!-- endinject -->'],
          js: ['<!-- inject:js -->', '<!-- endinject -->']
      },
    })
  ]
  ...
}

webpack�����html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="keywords" content="" />
    <meta http-equiv="description" content="" />
    <title>html-replace-webpack-plugin demo</title>

    <!-- inject:css -->
    <link href="/static/css/index.css" rel="stylesheet">
    <!-- endinject -->
  </head>
  <body>

    <!-- inject:js -->
    <script type="text/javascript" src="/static/js/common.js"></script>
    <script type="text/javascript" src="/static/js/index.js"></script>
    <!-- endinject -->
  </body>
</html>

API

��API�html-webpack-plugin���

���API�

  • injectPointï¼�
    • Type: Array
    • Value: [startTag, endTag]
    • optionalï¼�å¦�æ��ä¸�设置此å��æ�°ï¼�å°�ä¸�html-webpack-pluginå��è�½ç�¸å��

Package Sidebar

Install

npm i html-tag-replace-webpack-plugin

Weekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • chersquwn