Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I copy files from a directory without it creating the whole source structure? #293

Closed
charliedavison opened this issue Oct 2, 2018 · 2 comments

Comments

@charliedavison
Copy link

I'm trying to use CopyWebpackPlugin to copy some files out of my node_modules folder and into my build folder.

new CopyWebpackPlugin([
     { from: 'node_modules/accounting/**', to: 'vendor/npm/' },
     { from: 'node_modules/angular/**', to: 'vendor/npm/' },

I would expect this to output to my build folder /build/vendor/npm/accounting and build/vendor/npm/angular respectively, but instead a node_modules folder is created - the files are actually outputted to build/vendor/npm/node_modules/accounting.

How can I prevent the node_modules folder being created and get my expected output?

@EdBoucher
Copy link

If you check out the branch referenced in this PR you can add a transformPath function to get the files into the right directory: #284

@bjbrewster
Copy link

For anyone else coming here from Google, transformPath is not in latest Webpack CopyWebpackPlugin. You would instead use the context arg like this:

      { context: 'node_modules/', from: 'accounting/**/*', to: 'vendor/npm/' },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants