【发布时间】:2019-02-23 21:27:34
【问题描述】:
我在使用 Nuxt.JS (Vue.js) 加载 .mp3 文件时遇到问题...
我试图在没有特定加载器的情况下加载文件,webpack 告诉他需要一个特定的文件加载器,当我在 nuxt.config.js 文件中添加 url-loader 时:
build: {
/*
** Run ESLint on save
*/
extend (config, { isDev, isClient }) {
if (isDev && isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
config.module.rules.push({
test: /\.(ogg|mp3|wav)$/i,
loader: 'url-loader'
})
}
}
抛出错误:
TypeError
Cannot read property 'middleware' of undefined
有人在 Nuxt.Js 中使用过其他加载器吗?
提前致谢!
【问题讨论】:
-
尝试使用
file-loader而不是url-loader。 -
不幸的是还不行:'(
-
该错误看起来与 mp3 无关。
-
你使用的是哪个 Webpack 版本?
-
我正在使用
webpack@3.12.0