feat: affine-embed-header

This commit is contained in:
alt0
2022-09-21 14:19:07 +08:00
parent 56cbd3ed5d
commit be4d66b203
4 changed files with 5 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
FROM node:16-alpine as builder FROM node:16-alpine as builder
ARG HUBSPOT_API_SECRET ARG AFFINE_EMBED_HEADER
WORKDIR /app WORKDIR /app
RUN apk add git && npm i -g pnpm@7 RUN apk add git && npm i -g pnpm@7
COPY . . COPY . .

View File

@@ -71,7 +71,7 @@ jobs:
tags: ${{ env.LOCAL_CACHE }} tags: ${{ env.LOCAL_CACHE }}
target: AFFiNE target: AFFiNE
build-args: | build-args: |
HUBSPOT_API_SECRET=${{ secrets.HUBSPOT_API_SECRET }} AFFINE_EMBED_HEADER=${{ secrets.AFFINE_EMBED_HEADER }}
- name: Build and push Docker image (AFFINE-Local) - name: Build and push Docker image (AFFINE-Local)
uses: docker/build-push-action@v3 uses: docker/build-push-action@v3

View File

@@ -4,7 +4,7 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<%= htmlWebpackPlugin.options.hubspotScript %> <%= htmlWebpackPlugin.options.embedHeaderScript %>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

View File

@@ -11,13 +11,7 @@ const TerserPlugin = require('terser-webpack-plugin');
const Style9Plugin = require('style9/webpack'); const Style9Plugin = require('style9/webpack');
const enableBundleAnalyzer = process.env.BUNDLE_ANALYZER; const enableBundleAnalyzer = process.env.BUNDLE_ANALYZER;
const embedHeaderScript = process.env.AFFINE_EMBED_HEADER;
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) { module.exports = function (webpackConfig) {
const config = getNxWebpackConfig(webpackConfig); const config = getNxWebpackConfig(webpackConfig);
@@ -185,7 +179,7 @@ module.exports = function (webpackConfig) {
), //favicon path ), //favicon path
template: path.resolve(__dirname, './src/template.html'), template: path.resolve(__dirname, './src/template.html'),
publicPath: '/', publicPath: '/',
hubspotScript: generateHubspotScript(), embedHeaderScript,
}), }),
new Style9Plugin(), new Style9Plugin(),
isProd && isProd &&