options object is not refreshed upon multiple calls
rodrigommv1987 opened this issue · 2 comments
Hi, I'm trying to get compiled different versions depending on some runtime values and I found this plugin very usefull, but I think I have found a bug.
When using this plugin on several webpack config objects, the output bundles always match the first of the passed objects.
For example this config object was always creating bundles matching the first of the objects in the array (page1):
module.exports = [
{
entry: {
page1: "./src/index.js",
},
...
module: {
rules: [
{
loader: "js-conditional-compile-loader",
options: {
gallery: false,
hero: true,
slider: false,
},
},
],
},
},
{
entry: {
page2: "./src/index.js",
},
...
module: {
rules: [
{
loader: "js-conditional-compile-loader",
options: {
gallery: false,
hero: true,
slider: true,
},
},
],
},
},
{
entry: {
page3: "./src/index.js",
},
...
module: {
rules: [
{
loader: "js-conditional-compile-loader",
options: {
gallery: true,
hero: false,
slider: false,
},
},
],
},
},
];After debugging a little the code of the loader, I found that in the index.js file, the options variable is defined outside of the exported function, it's always taking the value of the first call done to it, and not taking the passed config on succesive executions. This gets solved by removing the if on line #7.
Hope you find this useful.
Cheers!
Hi ,
I have fixed this problem, by this version:
js-conditional-compile-loader@1.0.14
Thanks a lot!
Working fine now!!