Skip to content

Instantly share code, notes, and snippets.

@aquilesb
Created July 10, 2019 02:39
Show Gist options
  • Save aquilesb/f65bda1a8f96e82f73e6f95cedb09625 to your computer and use it in GitHub Desktop.
Save aquilesb/f65bda1a8f96e82f73e6f95cedb09625 to your computer and use it in GitHub Desktop.
How to add pdf loader to vue-cli's project
module.exports = {
chainWebpack: config => {
config.module.rule('pdf')
.test(/\.(pdf)(\?.*)?$/)
.use('file-loader')
.loader('file-loader')
.options({
name: 'assets/pdf/[name].[hash:8].[ext]'
})
}
}
@WangNingning1994
Copy link

Dude, you saved my life!

@Joshua-Nweze
Copy link

I added the code you wrote but it isn't working
Here's what my config file looks like

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  chainWebpack: config => {
    config.module.rule('pdf')
      .test(/\.(pdf)(\?.*)?$/)
      .use('file-loader')
        .loader('file-loader')
        .options({
          name: 'assets/pdf/[name].[hash:8].[ext]'
        })

  }
})

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment