module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
}
]
}
}
在webpack的配置文件中 直接就是用了css-loader
而没有使用require或者import去引入
这是为什么呢?
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
}
]
}
}
在webpack的配置文件中 直接就是用了css-loader
而没有使用require或者import去引入
这是为什么呢?
Referencing loaders By convention, though not required, loaders are
usually named as XXX-loader, where XXX is the context name. For
example, json-loader.You may reference loaders by its full (actual) name (e.g.
json-loader), or by its shorthand name (e.g. json).The loader name convention and precedence search order is defined by
resolveLoader.moduleTemplates within the webpack configuration API.Loader name conventions may be useful, especially when referencing
them within require() statements; see usage below.
方档里有解释啊
loader
和你的 import xxx
不是一个东西。
loader
实际上是webpack
本身会去调用或者应用的函数而已,本质上,webpack
调用loader
的方法是 loader-runner
也就是说,当你在webpack中配置了loader之后,它自身会在需要的地方加载你的loader
,加载的方式就是:https://github.com/webpack/lo...
看你说没有啥文档,在loader-api
里面就有说明:
3 回答4.8k 阅读✓ 已解决
5 回答2k 阅读
3 回答1.4k 阅读✓ 已解决
2 回答2.5k 阅读✓ 已解决
2 回答1.9k 阅读✓ 已解决
3 回答1.1k 阅读✓ 已解决
1 回答3k 阅读✓ 已解决
你并没有直接用啊,你只是告诉webpack要用这个东西,怎么用是它的机制。