Saturday, 22 Aug 2015 - 14:28
Here I'm going to explain how I setup my web development environment on Linux. The process pretty much the same in MacOS.
I don't install any of the tools as root. All of them are put in my user home directory in ~/local/.
Installing NodeJs and NPM
To setup NodeJS and NPM I just run this wonderful script:
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc . ~/.bashrc mkdir ~/local mkdir ~/node-latest-install cd ~/node-latest-install curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 ./configure --prefix=~/local make install # ok, fine, this step probably takes more than 30 seconds... curl https://www.npmjs.org/install.sh | sh
I don't want to Java installed for all users so I just download and install it in ~/local/java/.
Here you can download Java 8 from Oracle. Just download and unzip in the directory of your choice. You'll probably need to add Java in your .bashrc.
export JAVA_HOME=$HOME/local/java export PATH=$HOME/local/bin:$JAVA_HOME/bin:$PATH
Easy with NPM:
npm install -g gulp
Installing Google Closure Compiler
The Closure Tools contain a few development tools. You can use them separately or all together.
The Closure Compiler will take your code output and minimized and optimized version of it. Download the latest version here.
mkdir ~/local/closure cd ~/local/closure unzip compiler-latest.zip
Also it is handy to create an alias for the compiler:
alias closure-compiler='java -jar ~/local/closure/compiler.jar'
With the compiler you can minimize/optimize single JS files using:
closure-compiler -O WHITESPACE_ONLY < file.js > file.min.js closure-compiler -O SIMPLE < file.js > file.opt.js closure-compiler -O ADVANCED < file.js > file.opt2.js
As usual, ADVANCED may break the code so use it only if you have plenty of unit tests in your application.