lelandrichardson / enzyme-example-karma-webpack

Example project with React + Enzyme + Karma + Webpack
MIT License
82 stars 28 forks source link

Exclude node_modules from webpack build #1

Closed alexanderchan closed 8 years ago

alexanderchan commented 8 years ago

Chai will complain if node_modules is included due to strict mode being applied. Also, excluding speeds the build time.

lelandrichardson commented 8 years ago

@alexanderchan I'd like to do this but now I'm not quite sure the right way to do it. The problem is kind of nuanced...

These enzyme-example-* projects are being used in the main enzyme repo to run the test suite. It runs the main enzyme suite, then cds into this repo's directory inside of node_modules and runs npm install && npm test.

The problem I was running into was that since the project folder in this case was now located inside of a higher up node_modules directory, webpack was ignoring every file. Any ideas on how to prevent node_modules in a more robust way that would still work in this (admittedly strange) test situation?

alexanderchan commented 8 years ago

@lelandrichardson, interesting case. I've updated this to exclude by path instead of regexp and it works for me when I npm run test:env -- karma-webpack from enzyme. imho it still looks like a normal webpack config so that's a bonus :smile:

I've also removed the webpack require, sorry I must have brought that in for another test I was doing and didn't remove it.

lelandrichardson commented 8 years ago

Awesome. Looks great! Thanks for fixing that for me :)