Copy-webpack-plugin: Copy empty folders

Created on 30 Nov 2016  路  5Comments  路  Source: webpack-contrib/copy-webpack-plugin

Hi,

Thanks for this plugin 馃憤
I have a static folder I want to copy to the dist folder. This folder contains three folders, like so:

  • static

    • assets

    • script

    • style

I want to copy these folders, regardless if they have content. Is that possible?
I currently have the following setup, and it only creates the folders in dist when they contain files:

new CopyWebpackPlugin([
    {
            context: path.join(paths.www, 'static'),
            from: '**/*',
            to: 'static',
    }
], {
        copyUnmodified: true
})

Is this not possible, or is there something with my config?

Most helpful comment

Is this still a limitation with webpack, three years later?

All 5 comments

Unfortunately, this is a limitation with webpack. It can't create empty folders. Only files, not directories, can be added to compilation.assets, which is how we use webpack to write the files. You could, in theory, add a '.empty' file to each directory to ensure they appear.

Is this still a limitation with webpack, three years later?

Id like to know how to copy empty folders lol

Tried it with webpack 4.44.2 and it's still an issue

Just add an empty file like .gitkeep file inside the directory you want to be copied
This way CopyWebpackPlugin will copy those empty folders (because they are not empty anymore)

Also, you can track those folders, for example with .gitignore

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jocs picture Jocs  路  4Comments

smashercosmo picture smashercosmo  路  6Comments

dmarcautan picture dmarcautan  路  5Comments

jbruni picture jbruni  路  3Comments

serut picture serut  路  3Comments