admin管理员组文章数量:1335106
I need to configure Webpack to accept and handle PDF files with url-loader
via the Vue Cli (latest).
vue.config.js
module.exports = {
configureWebpack: {
rules: [
{
test: /\.(pdf)(\?.*)?$/,
use: [
{
loader: 'url-loader',
options: {
name: 'files/[name].[hash:8].[ext]'
}
}
]
}
]
}
}
Does the above look correct or am I missing something? The docs on this are here: .md#basic-configuration
I get the error:
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. Configuration has an unknown property 'rules'.
I'm obviously missing something in my understanding here about how to augment the generated Webpack config in Vue.
Help appreciated! Thanks
I need to configure Webpack to accept and handle PDF files with url-loader
via the Vue Cli (latest).
vue.config.js
module.exports = {
configureWebpack: {
rules: [
{
test: /\.(pdf)(\?.*)?$/,
use: [
{
loader: 'url-loader',
options: {
name: 'files/[name].[hash:8].[ext]'
}
}
]
}
]
}
}
Does the above look correct or am I missing something? The docs on this are here: https://github./vuejs/vue-cli/blob/dev/docs/webpack.md#basic-configuration
I get the error:
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. Configuration has an unknown property 'rules'.
I'm obviously missing something in my understanding here about how to augment the generated Webpack config in Vue.
Help appreciated! Thanks
Share Improve this question asked Mar 2, 2018 at 10:55 Michael Giovanni PumoMichael Giovanni Pumo 14.8k18 gold badges99 silver badges145 bronze badges2 Answers
Reset to default 7Turns out, I was missing another level for the rules
array.
module: {}
So it should be in full:
module.exports = {
configureWebpack: {
module: {
rules: [
{
test: /\.(pdf)(\?.*)?$/,
use: [
{
loader: 'url-loader',
options: {
name: 'files/[name].[hash:8].[ext]'
}
}
]
}
]
}
}
}
My bad! Hopefully this helps someone out there.
For coffeescript
and vue-cli
version 3, I needed to npm install -D coffee-loader
and then create this file as vue.config.js
:
module.exports = {
configureWebpack: {
module: {
rules: [
{
test: /\.coffee$/,
use: [
{
loader: 'coffee-loader',
options: {
sourceMap: true
}
}
]
}
]
}
}
}
本文标签: javascriptHow to add support for PDF files with Vue Cli 3Stack Overflow
版权声明:本文标题:javascript - How to add support for PDF files with Vue Cli 3? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742383134a2464492.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论