Reputation: 175
I am trying to move static folder in build/ to another directory using react-app-rewired. The final result should be build/assets/static. I am stuck for an hours on this one. My config-overrides.js is the following:
module.exports = function override(config, env) {
config.output = {
...config.output, // copy all settings
filename: "assets/static/js/[name].js",
chunkFilename: "assets/static/js/[name].chunk.js",
};
return config;
};
Can anyone help me with that. Right now It moves only the js folder from build/static to build/assets/static but I also want to move the media folder with images like this - build/assets/static/media. Thank you
Upvotes: 3
Views: 886
Reputation: 67
I solved this like this. I don't have experience with webpack, so I decided to console.log the config object to see what it is. There I discovered plugins object field which had MiniCssExtractPlugin object and options inside with similar settings that you changed with js files. So bacisally I did the same as you, just changed path a bit.
module.exports = function override(config, env) {
console.log(config.plugins);
config.plugins[5].options = { \\ plugins is an array of object where css plugin as at 5th index
...config.plugins[5].options,
filename: 'react/static/css/[name].[contenthash:8].css',
chunkFilename: 'react/static/css/[name].[contenthash:8].chunk.css'
}
config.output = {
...config.output, // copy all settings
filename: "react/static/js/[name].js",
chunkFilename: "react/static/js/[name].chunk.js",
};
return config;
};
Upvotes: 1