Skip to content

Instantly share code, notes, and snippets.

@evolkmann
Last active April 24, 2018 16:37
Show Gist options
  • Save evolkmann/0e5250b65777cd2354f2ccc9da10fb5b to your computer and use it in GitHub Desktop.
Save evolkmann/0e5250b65777cd2354f2ccc9da10fb5b to your computer and use it in GitHub Desktop.
Manage different environments in a simple web project
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