Last active
April 24, 2018 16:37
-
-
Save evolkmann/0e5250b65777cd2354f2ccc9da10fb5b to your computer and use it in GitHub Desktop.
Manage different environments in a simple web project
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
const gulp = require('gulp'); | |
const htmlReplace = require('gulp-html-replace') | |
const fs = require('fs'); | |
const injectEnv = (env) => { | |
return gulp.src('dist/index.html') | |
.pipe(htmlReplace({ | |
'environment-vars': `<script>${fs.readFileSync(`${env}.environment.js`).toString()}</script>` | |
})) | |
.pipe(gulp.dest('dist')); | |
}; | |
gulp.task('build:prod', () => { | |
return injectEnv('prod'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment