Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env query parameter. #368

Merged
merged 1 commit into from Feb 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions 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.
Expand Down Expand Up @@ -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 override 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
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Expand Up @@ -88,10 +88,12 @@ 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,
}),
};

delete userOptions.forceEnv;

const options = assign({}, defaultOptions, userOptions);

if (userOptions.sourceMap === undefined) {
Expand Down