Skip to content

Commit cfc1c38

Browse files
committed
make appname env var for use in analytics
1 parent 531ff8f commit cfc1c38

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webpack.config.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const path = require("path");
2+
const webpack = require("webpack");
23
const WorkboxPlugin = require("workbox-webpack-plugin");
34
const HtmlWebpackPlugin = require("html-webpack-plugin");
45
const CopyPlugin = require("copy-webpack-plugin");
@@ -13,6 +14,11 @@ if (!appName || !issues) {
1314
);
1415
}
1516

17+
// Define app name as an env var for use by the sendAnalyticsCF function
18+
const definePlugin = new webpack.DefinePlugin({
19+
"process.env.APP_NAME": JSON.stringify(packageJson.name),
20+
});
21+
1622
module.exports = (env, argv) => {
1723
if (argv.mode === "development") {
1824
console.log("RUNNING IN DEV MODE. Service worker will not generate.");
@@ -95,8 +101,14 @@ module.exports = (env, argv) => {
95101

96102
const plugins =
97103
argv.mode === "development"
98-
? [htmlPlugin, privacyHtmlPlugin, copyPlugin]
99-
: [htmlPlugin, privacyHtmlPlugin, copyPlugin, serviceWorkerPlugin];
104+
? [definePlugin, htmlPlugin, privacyHtmlPlugin, copyPlugin]
105+
: [
106+
definePlugin,
107+
htmlPlugin,
108+
privacyHtmlPlugin,
109+
copyPlugin,
110+
serviceWorkerPlugin,
111+
];
100112

101113
return {
102114
entry: "./src/index.js",

0 commit comments

Comments
 (0)