Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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