Ximo's Blog

My Twitter profileMy Telegram profileMy Codeforces profileMy LinkedIn profileMy Google+ profile

Saturday, 22 Aug 2015 - 14:28

My Web Development environment

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

Here you can get the latest version.

Installing Java

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

Install Gulp

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.

If you need other part of Closure such as the JavaScript library or the templating system check the official page.

Other

If I'm going to build a game I use Phaser while if I'm doing a web app I use AngularJS.

Previous posts

Saturday, 08 Aug 2015 - 21:20 - Using Go in programming contests

Saturday, 08 Aug 2015 - 16:35 - About this blog

Saturday, 08 Aug 2015 - 15:54 - (testing) Hello, World!


See the complete list of articles here.