Customizing the Asset Group Path in Webpack
You can set a save path for each asset group. This is done using the generator setting, specified for each group:
export default {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve('dist'),
},
module: {
rules: [
{
test: /\.png$/,
type: 'asset/resource',
generator: {
filename: 'images/[name].[hash][ext]'
}
}
]
},
plugins: [
new HtmlWebpackPlugin(),
],
};
Place all images with the extension .png in the folder images/png.
Place all images with the extension .jpg in the folder images/jpg.
Place all files with the extension .zip into the folder download.
Place all files with the extension .zip or .rar into the folder download.