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
関連記事

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

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

動画を切り抜くときのメモ
動画の切り抜きの方法。あわせて生放送から切り抜くときの方法も。 事前準備 カメラ ...

[AWS Amplify] ログイン画面を日本語化する
まずプラグインを公開してくれている方がいるので、こちらを使います。 npm in ...

[AWS Amplify] API(Graphql)のパブリック設定。複数認証。subscriptionまで。
前回公開したアプリでは、ログインした人たちが投稿と投票をできて、ログインしていな ...
ディスカッション
コメント一覧
Golden Empire game is pretty cool! I’m really enjoying playing it! Check it out here: golden empire game