1.0.0 • Published 2 years ago

cloud-html-inject-plugin v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

cloud-html-inject-plugin

根据指定配置,在webpack构建时修改为指定的值

用法如下:

// webpack.config.js
const CloudHtmlInjectPlugin = require('cloud-html-inject-plugin');

{
  ...,
  plugins: [
    new CloudHtmlInjectPlugin({
      // 需要修改的文件的路径
        htmlEntry: path.resolve(__dirname, './index.html'),
        // 替换的配置
        replace: {
          SCRIPT_A: `
            (function (win){ console.log(win); })(window);
          `,
          TITLA_A: '标题',
          STR_A: `这是输入替换的一段字符串`
        }
      })
  ],

}
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title><%TITLA_A%></title>
</head>
<body>
  <script><%SCRIPT_A%></script>
  <div><%STR_A%></div>
</body>
</html>