Skip to content

Commit

Permalink
Merge pull request #104 from premasagar/feature/optimize
Browse files Browse the repository at this point in the history
Feature/optimize
  • Loading branch information
adhipg committed Nov 14, 2013
2 parents ff34e6c + 5257a8b commit b66e4eb
Show file tree
Hide file tree
Showing 44 changed files with 673 additions and 750 deletions.
2 changes: 1 addition & 1 deletion .bowerrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"directory": "app/lib"
"directory": "src/lib"
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
node_modules/
config.js
compiled/**/*.*
app/lib/
src/lib/
dist/
example-widget/
build/
86 changes: 79 additions & 7 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-bower-release');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-shell');
grunt.initConfig({
bower: grunt.file.readJSON('bower.json'),

clean: {
all: {
src: ["compiled", "dist"]
src: ["build", "compiled", "dist"]
}
},

uglify: {
sqwidget: {
files: {
'build/sqwidget-min.js': ['build/sqwidget.js']
}
}
},

connect: {
publisher: {
options: {
Expand All @@ -24,24 +37,83 @@ module.exports = function(grunt) {
}
}
},
karma: {
integration: {
configFile: 'karma.conf.js'

requirejs: {
compile: {
options: {
baseUrl: "src",
out: 'dist/<%= bower.name %>.js',
paths: {
requirejs: 'lib/requirejs/require',
domReady: 'lib/requirejs-domready/domReady',
},
include: ['requirejs', 'sqwidget'],
wrap: {
startFile: 'src/_wrapper/top.js',
endFile: 'src/_wrapper/bottom.js'
},
optimize: 'uglify2',
//optimize: 'none',
//required for source maps, we should probably have 2 configs one
//without source maps or uglification
preserveLicenseComments: false,
generateSourceMaps: true
}
}
},
karma: {
options: {
configFile: './karma.conf.js',
browsers: ['Chrome', 'Firefox']
},
unit: {
background: true
},
//continuous integration mode: run tests once in PhantomJS browser.
continuous: {
singleRun: true,
browsers: ['PhantomJS']
},
},

shell: {
build_example: {
options: { stdout: true, stderr: true },
command: "./build_example.sh"
}
},

watch: {
test: {
files: ["test/fixture/*.js", "src/*.js", "test/spec/*.js"],
tasks: ["karma:unit:run"]
},
sqwidget: {
files: ["src/*.js", "test/spec/*.js"],
tasks: ["karma:unit:run", "build"]
},
scaffold: {
files: ["grunt-scaffold/root/main.js", "grunt-scaffold/root/app/**/*.js", "grunt-scaffold/**/*.tmpl"],
tasks: ["build"]
}
},

bowerRelease: {
stable: {
options: {
endpoint: 'git://github.com/premasagar/sqwidget.git',
packageName: "sqwidget.js",
stageDir: '.temp'
},
files: {
"sqwidget.js": ['dist/sqwidget.js'],
}
}
}

});
grunt.registerTask("build", ["shell:build_example"]);
grunt.registerTask("test", ["clean", "build", "karma"]);
grunt.registerTask("default", ["clean", "build", "connect", "watch"]);
grunt.registerTask("build", ["requirejs:compile"]);
grunt.registerTask("dist", ["clean", "build", "karma:unit"]);
grunt.registerTask("test", ["clean", "karma:unit", "watch:test"]);
grunt.registerTask("release", ["dist", "bowerRelease:stable"]);
};
48 changes: 14 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,25 @@
# Sqwidget

This is a WIP setup for helping develop widgets.
Sqwidget is a framework for adding components to a page in a way that ensures
they are self contained and namespaced.

## Scaffold

## Installation and Running
Installing sqwidget via bower will add a 'sqwidget' scaffold to your grunt
config. You can start a new widget by typing the following inside a new project
directory:

`grunt-init sqwidget`

This will provide a simple sqwidget bundle for you to fill out.

## Development

```
npm install grunt-cli -g
npm install coffee-script -g
npm install bower -g
npm install
grunt
bower install
```


## Present Setup

This is a development only setup at present. It needs build tasks etc.

On running `grunt`, three development servers are launched:

* `index.html` is loaded from `http://localhost:8000`. This is to simulate the
third party website that will actually host the widget.
* `widget.js` is loaded from `http://localhost:8001`. This is to simulate the
sqwidget itself being loaded from a server.
* The actual widgets that use the embed code are loaded from
`http://localhost:8002`.

This setup ensures that we always develop with an environment that's close to
the real environment.


## To-Dos

* Add `cleanslate` or similar to `sqwidget`
* Write a couple of example widgets so that we know how they are supposed to be
loaded. These widgets should get their data from another server (via JSONP)
* Each widget may have CSS dependencies. Load them.
* Look into i18n work with RequireJS for internationalisation.
* If possible, remove the dependency on jQuery.
npm install
grunt test
...
```
100 changes: 0 additions & 100 deletions app/main.js

This file was deleted.

Loading

0 comments on commit b66e4eb

Please sign in to comment.