本質上,當您有一個使用多個加載器的文件類型時,請使用「use」。例如
module: {
rules: [
{
test: /\.less$/,
use: [
'style-loader',
...cssLoaders,
lessLoader
],
},
{
test: /\.css$/,
use: [
'style-loader',
...cssLoaders,
],
},
{
enforce: 'pre',
test: /\.jsx?$/,
loader: 'eslint-loader',
include: assetsDir,
},
{
test: /\.jsx?$/,
include: assetsDir,
loader: 'babel-loader',
},
{
test: /\.(jpe?g|png|gif|svg)($|\?)/i,
loader: 'url-loader', // Inline images if they're less than 2 KiB
options: {
limit: 2048,
name: '[name]-[sha1:hash:hex:10].[ext]',
}
},
{
test: /\.(eot|ttf|woff2?|htc)($|\?)/i,
loader: 'file-loader',
options: {
name: '[name]-[sha1:hash:hex:10].[ext]',
},
},
],
},
當我使用這樣的選項時,我收到了不推薦使用的警告。 – Alex
@Alex更具體。什麼是警告?我懷疑你指的是這個:https://github.com/babel/babel-loader/issues/422 – mpen
(node:5408)DeprecationWarning:loaderUtils.parseQuery()收到一個可能有問題的非字符串值,請參閱https://github.com/webpack/loader-utils/issues/56 在下一個主要版本的loader-utils中,parseQuery()將替換爲getOptions()。 – Alex