Created
October 27, 2016 20:06
-
-
Save heygambo/c13bbfc209e385dad2700d270fc7fa39 to your computer and use it in GitHub Desktop.
Environment variables for vue webpack frontends
This file contains 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
// src/config/dev.env.js | |
export default { | |
GOOGLE_MAPS_API_KEY: 'THE KEY' | |
} |
This file contains 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
// src/config/index.js | |
import _ from 'lodash' | |
import EnvConfig from 'env-config' | |
export default _.merge(EnvConfig, { | |
VERIFICATION_DURATION: 3600 | |
}) |
This file contains 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
// src/config/prod.env.js | |
export default { | |
GOOGLE_MAPS_API_KEY: 'THE PRODUCTION KEY' | |
} |
This file contains 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
// build/dev.env.js | |
module.exports = merge(baseWebpackConfig, { | |
resolve: { | |
alias: { | |
'env-config': path.resolve(__dirname, '../src/config/dev.config.js') | |
} | |
} | |
}) |
This file contains 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
// build/prod.env.js | |
var webpackConfig = merge(baseWebpackConfig, { | |
resolve: { | |
alias: { | |
'env-config': path.resolve(__dirname, '../src/config/prod.config.js') | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is my solution for environment variables that are available in a Vue webpack environment.
I've stripped anything else out so you can read the code better.