简体   繁体   English

如何在不进行缩小和优化的情况下构建和导出 Next.js

[英]How to do a Next.js Build and Export WIthout Minification and Optimization

How can I do a Next.js build and export without minifying and optimizing the output files?如何在不缩小和优化输出文件的情况下构建和导出 Next.js?

For compression, you would open your next.config.js and set it to false:对于压缩,您将打开next.config.js并将其设置为 false:

module.exports = {
  compress: false,
}

And for minify, you would do it in your webpack.config.js:对于缩小,您可以在 webpack.config.js 中执行此操作:

module.exports = {
  //...
  optimization: {
    minimize: false,
  },
};

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.使用next@^12.0.0将产生未缩小的 HTML、JS 和一些 CSS。

For Next v13 and up you want:对于 Next v13 及更高版本,您需要:

module.exports = {
  swcMinify: false,
}

Source 资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM