Skip to content

Commit

Permalink
Upgrade pdfjs
Browse files Browse the repository at this point in the history
  • Loading branch information
Joozty committed Apr 5, 2021
1 parent 3f19df0 commit bad4aa4
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 250 deletions.
27 changes: 18 additions & 9 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const path = require('path')

const withWorkers = require('@zeit/next-workers')
const withTM = require('next-transpile-modules')(['pdfjs-dist'])

const csp = require('./csp.config')
const helpers = require('./utils/helpers')

Expand Down Expand Up @@ -32,7 +29,7 @@ const nextConfig = {
]
},

webpack: (config) => {
webpack: (config, { defaultLoaders }) => {
const originalEntry = config.entry
config.entry = async () => {
const entries = await originalEntry()
Expand Down Expand Up @@ -86,6 +83,22 @@ const nextConfig = {
}
})

config.module.rules.push({
test: /\.+(js|jsx|mjs|ts|tsx)$/,
loader: defaultLoaders.babel,
include: (f) => f.includes('/node_modules/pdfjs-dist/lib/'),
})

rules.push({
test: /\.worker\.(js|ts)$/,
loader: 'worker-loader',
options: {
publicPath: `${nextConfig.assetPrefix}/_next/`,
filename: 'static/[hash].worker.js',
esModule: false,
},
})

Object.assign(config.resolve.alias, {
'@sentry/node': config.isServer ? '@sentry/node' : '@sentry/browser',

Expand All @@ -98,9 +111,5 @@ const nextConfig = {
return config
},
}
nextConfig.workerLoaderOptions = {
publicPath: `${nextConfig.assetPrefix}/_next/`,
name: 'static/[hash].worker.js',
}

module.exports = withTM(withWorkers(nextConfig))
module.exports = nextConfig
Loading

0 comments on commit bad4aa4

Please sign in to comment.