Closed jraller closed 7 years ago
What other tools do you have in mind? Where are you planning to use the configuration?
If you follow the book convention, then the invocation pattern is like this:
const config = require('./webpack.config')(env); // Pass env now
In that case env
would be undefined. Which other tools you mean? For example in React Styleguidist we support the fist variant.
@sapegin makes a really good point about env being undefined and it appears not just when the file is required, I set up the interior of my function with a switch on env, but added a default that exports my test configuration.
The tool I'm using it with is WallabyJS https://wallabyjs.com/
In section 4.3 the following code is shown:
but this changes things so that a function is exported rather than an object. In order to utilize the webpack.config.js file with other tools it was pointed out to me that I needed to call what I had required in in order to get the function. Alternatively changing the code to
would retain the expected behavior for the webpack.config.js file by turning it into an function expression instead of a function definition.