From 5365a236dd9c5237e2149aa95e7d94ebcf36b8ba Mon Sep 17 00:00:00 2001 From: "david.bashford" Date: Sat, 11 Apr 2015 08:36:30 -0400 Subject: [PATCH] Adding build v watch auto-flag to allow for 'defeaturing' things during a build that you want to leave in the code for development --- README.md | 4 ++++ src/index.js | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 530565b..d4a1199 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,10 @@ If both `master` and `child` are present, `defeature` will perform a smart merge `mimosa` will remove features when your run `mimosa watch` or `mimosa build`. +## `build` v `watch` exclusion + +A feature called `mimosa-build-exclude` is automatically recognized by mimosa-defeature. This included feature allows for excluding features based on whether Mimosa is running a `watch` or a `build`. When running a `build`, all code using the `mimosa-build-exclude` feature flag will be removed/commented. + Default Config ====== diff --git a/src/index.js b/src/index.js index 267e986..dd67def 100644 --- a/src/index.js +++ b/src/index.js @@ -31,6 +31,15 @@ var _prepareFeatures = function(mimosaConfig, options, next) { mimosaConfig.defeature.includedFeatures = includedFeatures; mimosaConfig.defeature.excludedFeatures = excludedFeatures; + // when running a build, add feature that + // allows defeaturing to be build v watch specific + // Allows for leaving things in for dev that need removing for build + if (mimosaConfig.isBuild) { + excludedFeatures.push("mimosa-build-exclude"); + } else { + includedFeatures.push("mimosa-build-exclude"); + } + next(); };