@@ -323,7 +323,8 @@ your `custom` callback function.
323
323
``` js
324
324
// Export from "./my-custom-loader.js" or whatever you want.
325
325
module .exports = require (" babel-loader" ).custom (babel => {
326
- function myPlugin () {
326
+ // Extract the custom options in the custom plugin
327
+ function myPlugin (api , { opt1, opt2 }) {
327
328
return {
328
329
visitor: {},
329
330
};
@@ -342,7 +343,7 @@ module.exports = require("babel-loader").custom(babel => {
342
343
},
343
344
344
345
// Passed Babel's 'PartialConfig' object.
345
- config (cfg ) {
346
+ config (cfg , { customOptions } ) {
346
347
if (cfg .hasFilesystemConfig ()) {
347
348
// Use the normal config
348
349
return cfg .options ;
@@ -353,8 +354,8 @@ module.exports = require("babel-loader").custom(babel => {
353
354
plugins: [
354
355
... (cfg .options .plugins || []),
355
356
356
- // Include a custom plugin in the options.
357
- myPlugin,
357
+ // Include a custom plugin in the options and passing it the customOptions object .
358
+ [ myPlugin, customOptions] ,
358
359
],
359
360
};
360
361
},
@@ -389,7 +390,7 @@ Given the loader's options, split custom options out of `babel-loader`'s
389
390
options.
390
391
391
392
392
- ### ` config(cfg: PartialConfig): Object `
393
+ ### ` config(cfg: PartialConfig, options: { source, customOptions } ): Object `
393
394
394
395
Given Babel's ` PartialConfig ` object, return the ` options ` object that should
395
396
be passed to ` babel.transform ` .
0 commit comments