How to copy JSON files in to your dist folder without create all directory

Version : Webpack 4

You can use copy-webpack-plugin to copy files or directory from your source directory to dist folder.

For example  I am going to copy all JSON files from inside the app folder to dist/assets/ folder

newCopyWebpackPlugin([{
from:'apps/**/*.json',
to:'assets',
flatten:true
}]),

Output

if you didn’t specify flatten = true , all the directory will create in dist folder like below

Leave a comment