Browse Source

build dist/ file with Grunt

Fixes #635

remove unnecessary Grunt options
fix for jsHint
pull/726/head
David DeSandro 11 years ago
parent
commit
56f9ba2af8
  1. 2
      .tm_properties
  2. 153
      Gruntfile.js
  3. 1
      bower.json
  4. 3898
      dist/isotope.pkgd.js
  5. 8
      dist/isotope.pkgd.min.js
  6. 3
      js/isotope.js

2
.tm_properties

@ -1,3 +1,3 @@
softTabs = true
tabSize = 2
excludeInFileChooser = "{$exclude,_site/*,bower_components}"
excludeInFileChooser = "{$exclude,_site/*,bower_components,node_modules}"

153
Gruntfile.js

@ -1,11 +1,16 @@
var getBannerComment = require('./tasks/utils/get-banner-comment.js');
/*jshint node: true, strict: false */
// -------------------------- grunt -------------------------- //
module.exports = function( grunt ) {
var banner = getBannerComment( grunt );
var banner = ( function() {
var src = grunt.file.read('js/isotope.js');
var re = new RegExp('^\\s*(?:\\/\\*[\\s\\S]*?\\*\\/)\\s*');
var matches = src.match( re );
var banner = matches[0].replace( 'Isotope', 'Isotope PACKAGED' );
return banner;
})();
grunt.initConfig({
// ----- global settings ----- //
@ -15,8 +20,8 @@ module.exports = function( grunt ) {
// ----- tasks settings ----- //
jshint: {
docs: [ 'js/controller.js', 'js/*/*.js' ],
options: grunt.file.readJSON('js/.jshintrc')
docs: [ 'js/**/*.js' ],
options: grunt.file.readJSON('.jshintrc')
},
requirejs: {
@ -27,9 +32,10 @@ module.exports = function( grunt ) {
'jquery-bridget/jquery.bridget',
'isotope/js/isotope'
],
out: 'build/isotope.pkgd.js',
out: 'dist/isotope.pkgd.js',
optimize: 'none',
paths: {
isotope: '../',
jquery: 'empty:'
},
wrap: {
@ -39,146 +45,43 @@ module.exports = function( grunt ) {
}
},
concat: {
'docs-js': {
src: [
// docs js
'js/controller.js',
'js/pages/*.js'
],
dest: 'build/js/isotope-docs.js'
},
'docs-css': {
src: [ 'css/*.css', '!css/isotope-docs.css' ],
dest: 'build/css/isotope-docs.css'
}
},
uglify: {
pkgd: {
files: {
'build/isotope.pkgd.min.js': [ 'build/isotope.pkgd.js' ]
'dist/isotope.pkgd.min.js': [ 'dist/isotope.pkgd.js' ]
},
options: {
banner: banner
}
},
'docs': {
files: {
'build/js/isotope-docs.min.js': [ 'build/js/isotope-docs.js' ]
}
}
},
// ----- handlebars templating ----- //
template: {
docs: {
files: {
'build/': 'content/**/*.*'
},
options: {
templates: 'templates/*.mustache',
defaultTemplate: 'page',
dataFiles: "data/*.json",
partialFiles: {
'submitting-issues': 'bower_components/isotope/CONTRIBUTING.mdown'
},
helpers: {
firstValue: function( ary ) {
return ary[0];
},
plusOne: function( str ) {
return parseInt( str, 10 ) + 1;
}
}
}
}
},
// ----- copy ----- //
copy: {
"public": {
files: [
{
expand: true, // enable dynamic options
cwd: 'public/', // set cwd, excludes it in build path
src: [ '**', '!.htaccess' ],
dest: 'build/'
}
]
},
css: {
files: [
{
expand: true, // enable dynamic options
cwd: 'css/', // set cwd, excludes it in build path
src: [ '*' ],
dest: 'build/css/'
}
]
},
js: {
files: [
{
expand: true, // enable dynamic options
cwd: 'js/', // set cwd, excludes it in build path
src: [ '**' ],
dest: 'build/js/'
}
]
},
bowerSources: {
// additional sources will be set in bower-list-map
src: [
'bower_components/jquery/jquery.min.js'
],
dest: 'build/'
}
},
watch: {
content: {
files: [ 'content/**/*.*', 'templates/*.mustache' ],
tasks: [ 'template' ]
},
"public": {
files: [ 'public/**' ],
tasks: [ 'copy:public' ]
},
css: {
files: [ 'css/*' ],
tasks: [ 'copy:css' ]
},
js: {
files: [ 'js/**' ],
tasks: [ 'copy:js' ]
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-requirejs');
grunt.loadNpmTasks('grunt-fizzy-docs');
grunt.loadTasks('tasks/');
grunt.registerTask( 'pkgd-edit', function() {
var outFile = grunt.config.get('requirejs.pkgd.options.out');
var contents = grunt.file.read( outFile );
// get requireJS definition code
var definitionRE = /define\(\s*'isotope\/js\/isotope'(.|\n)+isotopeDefinition\s*\)/;
var definition = contents.match( definitionRE )[0];
// remove name module
var fixDefinition = definition.replace( "'isotope/js/isotope',", '' )
// ./item -> isotope/js/item
.replace( /'.\//g, "'isotope/js/" );
contents = contents.replace( definition, fixDefinition );
grunt.file.write( outFile, contents );
grunt.log.writeln( 'Edited ' + outFile );
});
grunt.registerTask( 'default', [
'jshint',
'requirejs',
'pkgd-edit',
'int-bower',
'concat',
'uglify',
'template',
'copy'
'uglify'
]);
};

1
bower.json

@ -30,7 +30,6 @@
"test/",
"examples/",
"**/.*",
"tasks/",
"Gruntfile.js",
"package.json",
"notes.md"

3898
dist/isotope.pkgd.js vendored

File diff suppressed because it is too large Load Diff

8
dist/isotope.pkgd.min.js vendored

File diff suppressed because one or more lines are too long

3
js/isotope.js

@ -190,7 +190,8 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode
Isotope.prototype._getIsInstant = function() {
var isInstant = this.options.isLayoutInstant !== undefined ?
this.options.isLayoutInstant : !this._isLayoutInited;
return this._isInstant = isInstant;
this._isInstant = isInstant;
return isInstant;
};
// -------------------------- filter -------------------------- //

Loading…
Cancel
Save