javascript - Using CopyWebpackPlugin how can I copy files out of node_modules into a folder without it creating a node_modules f

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

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?

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?

Share Improve this question edited Oct 2, 2018 at 15:12 CD-jS asked Oct 2, 2018 at 14:11 CD-jSCD-jS 1,1191 gold badge15 silver badges33 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

For future reference, the actual correct answer is that I needed context -

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

Include a leading / to use the absolute output path

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

Because you're using a glob in your from path, the to path is relative to the resolved from paths. Github docs.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745261840a4619244.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信