Created
January 30, 2022 11:06
-
-
Save josfaber/d937ca0791bd359f43a2861cded6807a to your computer and use it in GitHub Desktop.
load .env in webpack config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config({ path: path.resolve( __dirname, '../../.env' ) }); | |
module.exports = { | |
... | |
plugins: [ | |
new HtmlWebpackPlugin( { template: './src/index.html' } ), | |
new webpack.DefinePlugin( { | |
"process.env": JSON.stringify(process.env) | |
} ), | |
], | |
... | |
}; | |
/** | |
Now in html file use <%= process.env.GTAG_ID %> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment