webpack 的 loader 顺序是什么? [英] What is the loader order for 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.
推荐答案
{
test: /\.css$/,
loaders: ['style'],
},
{
test: /\.css$/,
loaders: ['css'],
},
和
{
test: /\.css$/,
loaders: ['style', 'css'],
},
似乎是平等的.在功能方面,这与 style(css(file))
相同(感谢 Miguel).
appear to be equal. In function terms, this is the same as style(css(file))
(thanks Miguel).
请注意,在 loaders
中,它们从从右到左进行评估.
Note that within loaders
they are evaluated from right to left.
这篇关于webpack 的 loader 顺序是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!