Monday, June 30, 2014

sencha cmd, skip theme build.

Found Newbridge Green's bootstrap theme for Extjs4. Looks pretty good.

Except, he understands how this crap actually works and wrote the thing in plain sass. (not the extjs theme extension thing). So, I can't really add it to the framework generated by
sencha generate app

So, I don't. Now I need to figure out how to automatically copy his css over when I do
sencha app build
and figure out how to get rid of the stupid ruby compass compilation thingy that takes forever anyways.

I also want to not use YUI to compress, but rather uglifyjs2. This can be put into a grunt task.

Here's how you get rid of the sass build and slicing.
Go to
.sencha/app/sencha.cfg
and add the lines
skip.sass=1
skip.slice=1

Finally got rid of that crap.
Now, we want to stop using YUI.
Go to
.sencha/app/build.properties
and set the following lines.
build.compression.yui=0
build.compression.closure=1

build.compression.uglify=0

When I tried to use Uglify, I got the following error:
[ERR] 
[ERR] BUILD FAILED
[ERR] java.lang.UnsupportedOperationException: Not Yet Implemented
[ERR] 

[ERR] Total time: 10 seconds
Laughable.

Since closure takes forever, the best option is probably just to not use compression, and just use a grunt task to build after everything is concatenated. That includes uglifying the concatenated app.js file, copying the bootstrap theme to the build folder, and gzipping both of those files.

Here's the gruntfile config:

module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    shell: {
      sencha_app_build: {
        command: 'sencha app build'
      }
    },

    jshint: {
      options: {
        reporter: require('jshint-stylish')
      },
      main: ['Gruntfile.js', 'app/**/*.js']
    },

    uglify: {
      options: {
        banner: '/*\n Copyright <%= pkg.author %> \n <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> \n*/\n'
      },
      main: {
        files: {
           'build/production/<%= pkg.name %>/app.js': 'build/production/<%= pkg.name %>/app.js'
        }
      }
    },

    copy: {
      main: {
        src: 'resources/css/bootstrap.css',
        dest: 'build/production/<%= pkg.name %>/resources/'
      }
    },

    compress: {
      options: {
        mode: 'gzip'
      },
      js: {
        expand: true, //use whole filename
        src: ['build/production/<%= pkg.name %>/*.js'],
        dest: '.'
      },
      css: {
        expand: true,
        src: ['build/production/<%= pkg.name %>/resources/*.css'],
        dest: '.'
      }
    }

  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-shell');  //or grunt-exec, unsure which is better

  grunt.registerTask('default', ['shell', 'uglify', 'copy', 'compress']);


};



And that will do it! Just make sure that

  1. your package name in package.json is the same as your Sencha project name
  2. bootstrap.css is under resources/css
  3. you have all the dependencies in npm and run npm install!

Friday, June 27, 2014

New server, nginx + nodejs, github

Got a new AWS server.

Decided to switch from apache to nginx.

Had to figure out how to configure it.

Default inst. locations on RedHat are:
  • webroot at /usr/share/nginx/html
  • config file at /etc/nginx/nginx.conf
I followed some other tutorials to figure out how to configure the reverse proxy for node and nginx. The current method that I'm using is probably not THE best, but certainly works.

Needed to learn how to clone a private repo from a new machine. Also trying to actually learn how to use Github.

And check out this nice site: https://www.atlassian.com/git/

http://stackoverflow.com/questions/2505096/cloning-a-private-github-repo
Oh, so cloning private repos uses the git@github.com:username/repo.git format...
You also need to generate SSH keys to authenticate with Github:
https://help.github.com/articles/generating-ssh-keys#platform-linux

Terse.