Reputation: 103
How can I do a Next.js build and export without minifying and optimizing the output files?
Upvotes: 10
Views: 15057
Reputation: 16564
Here's a version of @matt-jensen's answer with Typescript types:
next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
// ...
/**
* @param {import('webpack').Configuration} webpackConfig
* @returns {import('webpack').Configuration}
*/
webpack(webpackConfig) {
return {
...webpackConfig,
optimization: {
minimize: false,
},
};
},
};
module.exports = nextConfig;
Upvotes: 2
Reputation: 1564
next.config.js
module.exports = (nextConfig) => {
return {
...nextConfig,
webpack(webpackConfig) {
return {
...webpackConfig,
optimization: {
minimize: false
}
};
}
};
};
Using next@^12.0.0
will produce unminified HTML, JS, and somewhat CSS.
Upvotes: 11
Reputation: 8412
For compression, you would open your next.config.js
and set it to false:
module.exports = {
compress: false,
}
And for minify, you would do it in your webpack.config.js:
module.exports = {
//...
optimization: {
minimize: false,
},
};
Upvotes: 12