File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import { init } from '@amplitude/analytics-browser';
88import { autocapturePlugin } from '@amplitude/plugin-autocapture-browser' ;
99
1010// Initialize Amplitude with your API key
11- const AMPLITUDE_API_KEY = import . meta . env . VITE_AMPLITUDE_API_KEY ;
11+ const AMPLITUDE_API_KEY = process . env . VITE_AMPLITUDE_API_KEY ;
1212
1313if ( AMPLITUDE_API_KEY ) {
1414 init ( AMPLITUDE_API_KEY , {
Original file line number Diff line number Diff line change 11import CopyPlugin from "copy-webpack-plugin" ;
22import TerserPlugin from "terser-webpack-plugin" ;
33import HtmlWebpackPlugin from "html-webpack-plugin" ;
4-
4+ import webpack from "webpack" ;
5+ import dotenv from "dotenv" ;
56import path from "path" ;
67
8+ const env = dotenv . config ( ) . parsed || { } ;
9+ const envKeys = Object . keys ( env ) . reduce ( ( acc , key ) => {
10+ acc [ `process.env.${ key } ` ] = JSON . stringify ( env [ key ] ) ;
11+ return acc ;
12+ } , { } ) ;
13+
14+
715const appConfig = {
816 mode : "production" ,
917 entry : {
@@ -52,6 +60,7 @@ const appConfig = {
5260 new HtmlWebpackPlugin ( {
5361 template : "./index.html" ,
5462 } ) ,
63+ new webpack . DefinePlugin ( envKeys ) ,
5564 ] ,
5665 optimization : {
5766 minimize : true ,
You can’t perform that action at this time.
0 commit comments