From 138ab518e8d6bf7a732c15e32ec2c32daa6a5416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Lavault?= Date: Thu, 2 Feb 2017 16:45:13 +0100 Subject: [PATCH] Add env query parameter. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #283 Signed-off-by: Maƫl Lavault --- README.md | 8 +++++--- src/index.js | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ab676806..11922b29 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# babel-loader -[![NPM Status](https://img.shields.io/npm/v/babel-loader.svg?style=flat)](https://www.npmjs.com/package/babel-loader) -[![Build Status](https://travis-ci.org/babel/babel-loader.svg?branch=master)](https://travis-ci.org/babel/babel-loader) +# babel-loader +[![NPM Status](https://img.shields.io/npm/v/babel-loader.svg?style=flat)](https://www.npmjs.com/package/babel-loader) +[![Build Status](https://travis-ci.org/babel/babel-loader.svg?branch=master)](https://travis-ci.org/babel/babel-loader) [![Build Status](https://ci.appveyor.com/api/projects/status/vgtpr2i5bykgyuqo/branch/master?svg=true)](https://ci.appveyor.com/project/danez/babel-loader/branch/master) [![codecov](https://codecov.io/gh/babel/babel-loader/branch/master/graph/badge.svg)](https://codecov.io/gh/babel/babel-loader) > Babel is a compiler for writing next generation JavaScript. @@ -89,6 +89,8 @@ module: { * `babelrc`: Default `true`. When `false`, will ignore `.babelrc` files (except those referenced by the `extends` option). + * `forceEnv`: Default will resolve BABEL_ENV then NODE_ENV. Allow you to ovveride BABEL_ENV/NODE_ENV at the loader level. Useful for isomorphic applications with different babel configuration for client and server. + __Note:__ The `sourceMap` option is ignored, instead sourceMaps are automatically enabled when webpack is configured to use them (via the `devtool` config option). ## Troubleshooting diff --git a/src/index.js b/src/index.js index 3c5caf81..c0bc5246 100644 --- a/src/index.js +++ b/src/index.js @@ -88,7 +88,7 @@ module.exports = function(source, inputSourceMap) { babelrc: exists(userOptions.babelrc) ? read(userOptions.babelrc) : resolveRc(path.dirname(filename)), - env: process.env.BABEL_ENV || process.env.NODE_ENV, + env: userOptions.forceEnv || process.env.BABEL_ENV || process.env.NODE_ENV, }), };