feat: add hubspot embed script

This commit is contained in:
alt0
2022-09-09 17:06:12 +08:00
parent a26ff35a7b
commit d77052ee1b
3 changed files with 96 additions and 0 deletions
+1
View File
@@ -4,6 +4,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title><%= htmlWebpackPlugin.options.title %></title>
<%= htmlWebpackPlugin.options.hubspotScript %>
</head>
<body>
<div id="root"></div>
+8
View File
@@ -12,6 +12,13 @@ const Style9Plugin = require('style9/webpack');
const enableBundleAnalyzer = process.env.BUNDLE_ANALYZER;
function generateHubspotScript() {
const hubspotApiSecret = process.env.HUBSPOT_API_SECRET;
if (hubspotApiSecret) {
return `<script type="text/javascript" id="hs-script-loader" async defer src="//js-na1.hs-scripts.com/${hubspotApiSecret}.js"></script>`;
}
}
module.exports = function (webpackConfig) {
const config = getNxWebpackConfig(webpackConfig);
@@ -175,6 +182,7 @@ module.exports = function (webpackConfig) {
), //favicon path
template: path.resolve(__dirname, './src/template.html'),
publicPath: '/',
hubspotScript: generateHubspotScript(),
}),
new Style9Plugin(),
isProd &&