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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s