-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Allow me to specify exactly which paths to load #1818
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
Comments
Do you link to any tests via entry points? Normally you would have a seperate webpack config that links to all the spec.ts files (or a central file that links to all spec.ts files). I remember back from my Angular days that it was especially finicky with tests. As a stop-gap solution, consider moving your |
Thanks for the quick reply! I'm not 100% sure what you mean by "link to tests via entry points". We have two entry points for production builds, As far as I understand how webpacker works, the separate webpack configs (including a separate one for dev/test that link to all the So I guess my question is how do I tell webpacker in I see how moving all of our dev dependencies to dependencies would solve this, but it seems like there should be a way to tell webpacker how to generate an environment-specific webpack config that only includes certain files. The only documentation I can find is this, which doesn't go into detail about how to use I need a development config that includes all |
I must admit, I know more about Webpack than WebpackER. That being said, it sounds like WebpackER is eagerly loading your
You could also be missing a needed exclude (exclude can be added for most loaders) Line 44 in e70deb3
Unfortunately that's all I got, hope it helps. |
Thanks for the tips.. I've tried excluding specs in our In case anyone else runs into the same issue,the workaround described here worked #440 (stopping webpacker from "enchancing" normal asset precompilation rake tasks), but we ended up just moving all of our dev dependencies to dependencies. |
I think I've run into a similar issue. We have a component folder structure like below:
I found that the Webpacker creates an I've traced my problem to this area in the environments/base file. In some cases, the This is an example of what I get when I log the contents of
My guess is that it matched the jsx file then matched the test.js file and overwrote the correct path (the .jsx file). I'm not sure how to solve this. One thought was adding an I tried adding exclude conditions to the rules but that had no affect. I'm not that great with webpack and in debugging why the exclude didn't work, it lead me to the above findings. My last option is to not use the yml at all and just create the webpack config myself. :( Anyone else have thoughts on this? |
Oh. I totally misunderstood the intention of "packs". Derp. Thanks! :D |
I ran in to a similar situation - it's very common convention in the react community (and as I'm learning the JS community as a whole) to put test & other files next to the code rather than in a separate testing folder structure like in rails. in my case I have:
a simple add to config/webpack/production.js environment.loaders.get('babel').exclude = [/\.test\.js$/, /\.stories\.js$/, environment.loaders.get('babel').exclude] Has me back and working. It would be slick to see this exposed in webpacker.yml as a configuration option as I'm sure all the different frameworks will need slightly different files excluded and doing it automatically as part of initial setup will save a lot of people that getting started headache. |
@JeremiahChurch I have the same file structure as you listed above and I was hoping your solution would work but I'm stilling seeing my react test files in the webpack analysis of the production build...any ideas? |
I ended up having to use this nasty regex in my application.js pack
|
@wileybaba Sorry that isn't working for you - I just checked that applications production config - that line is unchanged and still working. I also just tested it in a much simpler default production.js file - as seen below - it looks to be working as expected as well. process.env.NODE_ENV = process.env.NODE_ENV || 'production'
const environment = require('./environment')
environment.loaders.get('babel').exclude = [/\.test\.js$/, /\.stories\.js$/, environment.loaders.get('babel').exclude];
module.exports = environment.toWebpackConfig() |
Adding in this comment to help benefit those working on projects that follow a standard of placing all frontend test code into nested
|
@ecbrodie I wonder if using something like https://github.com/cherrry/ignore-loader would help. |
@akshaysmurthy +1. None of the other solutions worked for me. But adding the following to my
|
@akshaysmurthy that loader seems to be abandoned and only supports old webpack versions. My solution has been in place on my webpacker project for months now without issue. |
Based on this earlier comment I think we can close this issue. |
Our webpacker config appears to be loading all of our test files and helpers for production builds. I need to exclude any files that end with
.spec.ts
now because since upgrading to rails 5.2.1 dev dependencies are no longer installed, which breaks the build since the spec files are looking for dev dependencies which aren't there. I do need to include any that end with just.ts
, though (which are in the same directories as the ones withspec.ts
, per angular community guidelines).I see that webpacker automatically globs directories passed to
resolved_paths
, so I can't specify my own path there (i.e. the path I really want isapp/assets/angular/**/*[^spec].ts
, not justapp/assets/angular/**/*
). I also tried adding[^spec].ts
to the extensions list, hoping webpacker would generate a path likeapp/assets/angular/**/*[^spec].ts
, but it does not.How do I tell webpacker to load only
.ts
files inapp/assets/angular
that do not end withspec.ts
?The text was updated successfully, but these errors were encountered: