EN
JavaScript - minify js files with google-closure-compiler under npm on Windows
9
points
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:
- usage
npm
/npx
, - installation with
npm
.
Simple usage:
npx google-closure-compiler --js=input.js --js_output_file=output.min.js
Note: online version is available here.
Check out this article - JavaScript - minify js files with Google Closure Compiler Service (online)
Compression result:
Note: go to instalation section if you are using compiler first time.
Installation example
In this section, we can see how to install google-closure-compiler
using npm
. It can take few seconds so be patient until installation will succeed.
Run the following command:
npm install -g google-closure-compiler
Where -g
means global installation.
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