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を自 ...

Vue.jsでソーシャルボタンを出す
ソーシャルボタンをつけたくなった。公開されているコンポーネントで簡単に作れないだ ...

COVID-19 データ可視化サイトメモ
以下いろいろ見て回りながらメモしたもの Qiitaにも投稿している。 Track ...

[ AWS Amplify ]リアルタイム投票所ジェネレーターを作ったらなかなかいいのが出来ました。
アドレス 画像のような投票所を作れるサイトを作ってみました。聴衆がいる場面で使う ...
ディスカッション
コメント一覧
Golden Empire game is pretty cool! I’m really enjoying playing it! Check it out here: golden empire game
1winplinko… is okay. Its got some pretty neat features. Check out 1winplinko!
Just tried my luck at Casio3363. Gotta say, nothing super special, but the site is easy to figure out. Has those classic games everyone loves, so can’t really complain. Check it casio3363 out!
888slots77, yeah, pretty straightforward. Lots of slots, like the name says. If you’re a slot head, give it a whirl. I will say there is a variety on the site. Here’s the link 888slots77