LoginSignup
0
0

More than 3 years have passed since last update.

uglifyjsが圧縮時に格納するフォルダがないとエラーを吐く問題を追求してみた

Last updated at Posted at 2020-12-06

この記事の対象者

JSファイルを圧縮して、特定のフォルダに生成したいと思っている方

公式ではIssueが上がっていた

要約すると、uglifyjsはたくさんのタスクを処理しているからフォルダ生成はuglifyjsでは行うべきではないとのことでIssueがCloseされている。

プルリク通りに圧縮前にフォルダを用意することにしてみた

"minify:js": "mkdir -p 'dist/js' && uglifyjs 'src/js/index.js' -c --output 'dist/js/index.min.js'"

Brosersyncと組み合わせてみる

"minify:js": "mkdir -p dist/js && uglifyjs 'src/js/index.js' -c --output 'dist/js/index.min.js'",
"build:js": "yarn minify:js",
"watch:js": "onchange 'src/js/**/*.js' -- yarn build:js",
"server": "browser-sync start --server 'dist' --files 'dist'",
"dev": "yarn watch:js & yarn server"

最後に

Webpackを使う程でもない!!!
だけどJSファイルを修正したら特定のフォルダに圧縮した状態で生成したい時には使えると思いました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0