Skip to content

Instantly share code, notes, and snippets.

@evolkmann
evolkmann / gulpfile.js
Last active April 24, 2018 16:37
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'));