Generate source maps during production build in your Next.js project
npm install --save @zeit/next-source-maps
or
yarn add @zeit/next-source-maps
Create a next.config.js
// next.config.js
const withSourceMaps = require('@zeit/next-source-maps')
module.exports = withSourceMaps({
webpack(config, options) {
return config
}
})
Then you can run a regular build command and source maps will be outputted for the bundles
npm run build
By default devtool is source-map
. If you want use different devtool type, you can pass it with options.
// next.config.js
const withSourceMaps = require('@zeit/next-source-maps')({
devtool: 'hidden-source-map'
})
module.exports = withSourceMaps(
{
webpack(config, options) {
return config
}
}
)