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

Excluding vs testing files #1127

Closed
stefanvermaas opened this issue Dec 19, 2017 · 2 comments
Closed

Excluding vs testing files #1127

stefanvermaas opened this issue Dec 19, 2017 · 2 comments

Comments

@stefanvermaas
Copy link
Contributor

Hi all,

A recent change to the file-loader that is included in webpacker broke our loaders implementation (in 3.2.0). The problem was that before this update a certain number of files was included/tested for the file-loader matcher, but now certain files were excluded from the file-loader.

I'm wondering why exclude is used in favour of test? It seems excluding file extensions makes it harder to maintain and a hell to debug the actual problem.

If people still want to use exclude in favour of the use action, I would like to propose to also add .md to the list.


I've fixed things on our side by adding .md files to the list of files to be excluded (in case any one is running into the same problems).

# config/webpack/environment.js
const { environment } = require('@rails/webpacker');

// - Alter the fileLoader exclude statement to make sure markdown files aren't loaded by the file-loader
const fileLoader = environment.loaders.get('file');
fileLoader.exclude = /\.(js|jsx|coffee|ts|tsx|vue|elm|scss|sass|css|html|json|md)?(\.erb)?$/

module.exports = environment;
@gauravtiwari
Copy link
Member

I'm wondering why exclude is used in favour of test?

@stefanvermaas The idea was to use file-loader as last loader to process certain types of files. The earlier setup had some conflicts, say if you have used react-svg-loader to process svg files and file loader also processed svg files. In 3.1.0, we used oneOf option which solved this problem but then loaders which were using multiple transformation started failing (erb loader) since it was using first matching loader from the list.

The current setup is almost there except we now have to manually exclude files we don't want file loader to process. Perhaps, we can offer an API for configuring file loader extensions instead of copying loader to environment.js.

environment.loaders.file.exclude('md')
environment.loaders.file.exclude(['md', 'svg'])

What do you think?

@gauravtiwari
Copy link
Member

Lets revert this change since it doesn't solve any problem, it did with oneOf loaders but since that got reverted lets revert this change too.

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

2 participants