Next.jsでビルド時にconsole.log等を削除する
IT記事,Next.jsterser-webpack-plugin
terser-webpack-pluginを使う方法。動いてるっぽい
installする
npm install terser-webpack-plugin --save-devnext.config.jsに追記する
const TerserPlugin = require("terser-webpack-plugin");
const isProd = process.env.NODE_ENV === "production";
module.exports = {
reactStrictMode: true,
webpack: (config, options) => {
config.optimization.minimize = isProd;
config.optimization.minimizer = [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: isProd,
},
},
extractComments: "all",
}),
];
return config;
},
};
drop_console 参考 https://github.com/mishoo/UglifyJS#compress-options
extractComments 参考 https://github.com/webpack-contrib/terser-webpack-plugin#extractcomments
関連記事

[Vue・terser-webpack-plugin] ビルド時にconsole.logを除去
Vue Cliでプロジェクトを作ったとして、ビルド時にconsole.logを自 ...

Reactでビルド時にconsole.logを除去
Reactでwebpackのterser pluginでconsole.logを ...

AWS Amplifyで匿名掲示板を作ってみた
AWS Amplifyで匿名掲示板を作ってみた 以下のURL いろんな機能がまっ ...

NotionのページをWordPressと同期する方法
Notionの方でブログ記事を書き、それを個人ブログのWordpressに投稿で ...

[ AWS Amplify + Vue.js ] Authでログイン画面作る
この記事では AWS Amplify の@aws-amplify/ui-vueを ...
ディスカッション
コメント一覧
Golden Empire game is pretty cool! I’m really enjoying playing it! Check it out here: golden empire game