cloud-html-inject-plugin

1.0.0 • Public • Published

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>

Readme

Keywords

none

Package Sidebar

Install

npm i cloud-html-inject-plugin

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

2.64 kB

Total Files

3

Last publish

Collaborators

  • shuyunfe