Skip to content
This repository has been archived by the owner on Jan 16, 2018. It is now read-only.

Structured objects in the loader list #11

Open
ide opened this issue Jun 4, 2015 · 6 comments
Open

Structured objects in the loader list #11

ide opened this issue Jun 4, 2015 · 6 comments

Comments

@ide
Copy link

ide commented Jun 4, 2015

Currently to specify a loader you can write:

loaders: [
  { test: /\.js$/, loader: 'babel', query: {stage: 0, optional: ['runtime']} }
]

but this does not support multiple loaders. For that, only the string syntax is supported: react-hot!babel?stage=0&optional[]=runtime. I would like to be able to use the object literal syntax to specify multiple loaders with query parameters:

loaders: [
  {
    test: /\.js$/,
    loaders: [
      { loader: 'react-hot' },  // or just 'react-hot', using the string syntax as shorthand
      { loader: 'babel',  query: {stage: 0, optional: ['runtime'] }
    ]
  }
]
@sokra
Copy link
Member

sokra commented Jul 18, 2015

Looks like a good idea. Do you want to send a PR?

@ide
Copy link
Author

ide commented Jul 25, 2015

I probably won't get around to this for awhile but it is a good PR for the community to contribute.

@andyhite
Copy link

andyhite commented Jan 6, 2016

I just issued a pull request earlier today that addresses this.

@sokra
Copy link
Member

sokra commented Jan 7, 2016

Oh thanks, could you "move" this PR to the webpack repo, as webpack/core is obsolute with webpack 2. The code has been moved into:

  • webpack/webpack-sources
  • webpack/loader-runner
  • webpack/webpack

@sokra
Copy link
Member

sokra commented Jan 7, 2016

Or better wait, the loader stuff will change anyway with webpack 2, so maybe the LoadersList become obsolete too...

@barroudjo
Copy link

Just to let you know, you can use Node querystring module to accomplish this:

var queryObject = {presets: ['es2015', 'runtime'], otherQueryParam: 'foobar'};
var query = require('querystring').stringify(queryObject);
config.loaders = [{
    test: /\.js$/,
    loaders: ['ng-annotate', 'babel?' + query]
}];

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants