walts81 / brunch-preprocessor

node module used by js-preprocess-brunch and html-preprocess-brunch plugins
MIT License
0 stars 0 forks source link

buildEnv config value produces brunch warning #1

Open paulmedynski opened 5 years ago

paulmedynski commented 5 years ago

The choice of the config option buildEnv causes brunch to emit the following warning when it parses the brunch-config.js:

12:26:17 - warn: config.overrides.test-module.buildEnv: perhaps you meant buildPath

Moving this config option into a js-preprocess plugin section would avoid the problem and better align js-preprocess-brunch's options with the way other plugin options are specified.

Right now, brunch-config.js looks like this:

{
  buildEnv: 'DEBUG'
}

Moving into a plugin section would look like this:

{
  plugins:
  {
    'js-preprocess':
    {
      buildEnv: 'DEBUG'
    }
  }
}
paulmedynski commented 5 years ago

Opened this in js-preprocess-brunch by mistake. Moved here.

paulmedynski commented 5 years ago

Here's the diff I'm patching index.js with to solve this problem:

diff -u -r -x package.json node_modules/brunch-preprocessor/lib/index.js new_node_modules/brunch-preprocessor/lib/index.js
--- node_modules/brunch-preprocessor/lib/index.js       2016-09-08 12:37:01.000000000 -0300
+++ new_node_modules/brunch-preprocessor/lib/index.js   2019-04-18 12:54:38.631672148 -0300
@@ -18,6 +18,15 @@
         buildEnv: 'debug'
       };
     }
+    // If our plugin section exists and contains a buildEnv value, use that
+    // instead of the root-level buildEnv.
+    else if (config.plugins !== undefined
+             && config.plugins['js-preprocess'] !== undefined
+             && config.plugins['js-preprocess'].buildEnv !== undefined)
+    {
+      config.buildEnv = config.plugins['js-preprocess'].buildEnv;
+    }
+
     while (matched = getNextStatement(data)) {
       before = data.substring(0, matched.index);
       after = data.substring(matched.endIndex, data.length);