Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the loader order for webpack?

Tags:

webpack

When I have a loader configuration with multiple tests matching a file, I would expect only the first matching loader to be used but that doesn't seem to be the case.

I tried reading the source but even when I found the bit that I think implements the loading I can't understand how it behaves.

The documentation doesn't mention how that situation should behave either.

like image 915
w00t Avatar asked Aug 26 '15 18:08

w00t


People also ask

Does the order of loaders matter in webpack?

Yes, although I like to avoid that because then you cannot decide at build time if the file should be a link or embedded. You can also start with !! to skip any other loaders BTW…

How does webpack file loader work?

Webpack goes through all the import ed and require d files in your project, and for all those files which have a . svg extension, it uses as an input to the webpack file loader. For each of these files, the file loader emits the file in the output directory and resolves the correct URL to be referenced.

What are 4 core concept of webpack?

There are four basic concepts in webpack: entry , output , modules and plug-ins . These configurations are added in webpack.


1 Answers

{     test: /\.css$/,     loaders: ['style'], }, {     test: /\.css$/,     loaders: ['css'], }, 

and

{     test: /\.css$/,     loaders: ['style', 'css'], }, 

appear to be equal. In function terms, this is the same as style(css(file)) (thanks Miguel).

Note that within loaders they are evaluated from right to left.

like image 195
Juho Vepsäläinen Avatar answered Oct 04 '22 12:10

Juho Vepsäläinen