You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your enhancement related to a problem? Please describe.
I was wondering what is behind the choice of allowing developers to modify the toolkit configuration via package.json and filenames.config.js instead of having something like a toolkit.config.js at the project root?
For my specific use case, I am trying to implement dynamic entries but modifying just the entry within a custom webpack config isn't enough because other functions throughout the build process rely on getTenUpScriptsConfig() to return the entries. Maybe there might be other use cases where it would be handy having the entire toolkit configuration customizable with js?
I didn't want to create a PR because I'm sure you have your reasons for the current structure, but I am able to easily accomplish what I'm looking for by making the following change to utils/config.js:
/**
* Returns 10up-scripts config either from package.json or toolkit.config.js with default values
*
* @returns {object}
*/
const getTenUpScriptsConfig = () => {
const packageJson = getPackage();
const configJS = 'toolkit.config.js';
const config = packageJson['10up-toolkit'] || packageJson['@10up/scripts'] || hasProjectFile(configJS) && require(fromProjectRoot(configJS));
const defaultConfig = getDefaultConfig();
if (!config) {
return defaultConfig;
}
return {
// override default configs with user-defined config
...defaultConfig,
...config,
// these properties must be merged
filenames: {
...defaultConfig.filenames,
...config.filenames,
},
paths: {
...defaultConfig.paths,
...config.paths,
},
};
};
Designs
No response
Describe alternatives you've considered
As mentioned, I've also tried modifying a custom webpack.config.js at the project root but it doesn't allow for the dynamic entries to be piped into the rest of the build process.
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
I actually like the idea of a single toolkit.config.js file and I'd be open to merging support for it if you submit a PR. I'd still like to support package json config though.
Is your enhancement related to a problem? Please describe.
I was wondering what is behind the choice of allowing developers to modify the toolkit configuration via
package.json
andfilenames.config.js
instead of having something like atoolkit.config.js
at the project root?For my specific use case, I am trying to implement dynamic entries but modifying just the
entry
within a custom webpack config isn't enough because other functions throughout the build process rely ongetTenUpScriptsConfig()
to return the entries. Maybe there might be other use cases where it would be handy having the entire toolkit configuration customizable with js?I didn't want to create a PR because I'm sure you have your reasons for the current structure, but I am able to easily accomplish what I'm looking for by making the following change to
utils/config.js
:Designs
No response
Describe alternatives you've considered
As mentioned, I've also tried modifying a custom
webpack.config.js
at the project root but it doesn't allow for the dynamic entries to be piped into the rest of the build process.Code of Conduct
The text was updated successfully, but these errors were encountered: