Languages
[Edit]
EN

JavaScript - minify js files with google-closure-compiler under npm on Windows

9 points
Created by:
Marcin
2544

In this short article we would like to show how to useĀ google-closure-compiler to compile js files to minified versions (*.min.js) on Windows.

The article contains two parts:

  1. usage npm / npx,
  2. instalation with npm.

Simple usage:

npx google-closure-compiler --js=input.js --js_output_file=output.min.js

Note:Ā online version is availableĀ here.

Compression result:

js file compressed with google-closure-compiler
js file compressed with google-closure-compiler

Note: go to instalation section if you are using compiler first time.

Instalation example

In this section we can see how to installĀ google-closure-compilerĀ using npm. It can take few seconds so be patient until instalation will succeed.

Run follwoing command:

npm install -g google-closure-compiler

Where -g means global instalation.

Example output:

C:\Users\john\AppData\Roaming\npm\google-closure-compiler -> C:\Users\john\AppData\Roaming\npm\node_modules\google-closure-compiler\cli.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: google-closure-compiler-osx@^20200920.0.0 (node_modules\google-closure-compiler\node_modules\google-closure-compiler-osx):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for google-closure-compiler-osx@20200920.0.0: wanted {"os":"darwin","arch":"x64,x86"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: google-closure-compiler-linux@^20200920.0.0 (node_modules\google-closure-compiler\node_modules\google-closure-compiler-linux):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for google-closure-compiler-linux@20200920.0.0: wanted {"os":"linux","arch":"x64,x86"} (current: {"os":"win32","arch":"x64"})

+ google-closure-compiler@20200920.0.0
added 28 packages from 73 contributors in 271.338s

References

  1. google-closure-compiler online version
Hey šŸ‘‹
Would you like to know what we do?
  • Dirask is online IT community for professionals and hobbyist to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.