makenv
A minimal module and CLI to make project environment configurations
Installing
npm install -g makenv
npm install --save-dev makenv
CLI
$ makenv
output
{
"name": "awesome-project",
"description": "Example description pulled from package.json",
"homepage": "http://awesomeproject.com"
}
Use case
frontend.js
var appConfigurations = require('./env.json')
Module
var env = require('makenv')
output
{
name: 'example',
description: 'Example description pulled from package.json',
homepage: 'http://example.com',
mode: 'development',
production: false,
development: true,
root: '/Users/johnsmith/awesome-project/',
modules: [ 'node_modules', 'bower_components' ],
paths: {
api: 'api',
components: 'components',
images: 'images',
providers: 'providers',
public: 'public',
scripts: 'scripts',
styles: 'styles',
views: 'views'
}
}
Use case
gulpfile.js
var gulp = require('gulp')
var sass = require('gulp-sass')
var env = require('makenv')
gulp.task('sass', function () {
return gulp.src( env.paths.styles + '/**/*.{sass,scss}')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest( env.paths.public ));
});
gulp.task('sass:watch', function () {
gulp.watch(env.paths.styles + '/**/*.{sass,scss}', ['sass']);
});
webpack.config.js
var webpack = require('webpack')
var env = require('makenv')
module.exports = {
debug: env.development ? true : false,
devtool: env.development ? '#eval-source-map' : null,
context: `${__dirname}/${env.paths.scripts}`,
entry: env.development ? ['webpack-hot-middleware/client?reload=true', './'] : ['./'],
output: {
path: `${__dirname}/${env.paths.public} `
},
resolve: {
extensions: ['', '.js','.jsx'],
root: env.root,
alias: env.paths,
modulesDirectories: env.modulesDirectories
},
}