Enhancement : full piskel build deployed to dest

Use grunt [default] to build the application.
Target dest with a webserver to launch the application.
This commit is contained in:
jdescottes 2014-05-05 22:36:34 +02:00
parent b7362c7082
commit bc23e9cea6
4 changed files with 31 additions and 16 deletions

7
.gitignore vendored
View file

@ -12,15 +12,12 @@ npm-debug.log
# git stackdumps # git stackdumps
*.stackdump *.stackdump
# builds
build/*.js
build/*.css
# diffs # diffs
diff.txt diff.txt
# Closure compiler generated JS binary. # build destination
build/closure/closure_compiled_binary.js dest
# marked as private # marked as private
*.private.* *.private.*

View file

@ -36,6 +36,10 @@ module.exports = function(grunt) {
}; };
grunt.initConfig({ grunt.initConfig({
clean: {
before: ['dest'],
after: ['build/closure/closure_compiled_binary.js']
},
jshint: { jshint: {
options: { options: {
indent:2, indent:2,
@ -79,11 +83,11 @@ module.exports = function(grunt) {
separator : ';' separator : ';'
}, },
src : piskelScripts, src : piskelScripts,
dest : 'build/piskel-packaged.js' dest : 'dest/js/piskel-packaged.js'
}, },
css : { css : {
src : piskelStyles, src : piskelStyles,
dest : 'build/piskel-style-packaged.css' dest : 'dest/css/piskel-style-packaged.css'
} }
}, },
uglify : { uglify : {
@ -92,10 +96,20 @@ module.exports = function(grunt) {
}, },
my_target : { my_target : {
files : { files : {
'build/piskel-packaged-min.js' : ['build/piskel-packaged.js'] 'dest/js/piskel-packaged-min.js' : ['dest/js/piskel-packaged.js']
} }
} }
}, },
copy: {
main: {
files: [
{src: ['src/piskel-boot.js'], dest: 'dest/piskel-boot.js'},
{src: ['src/js/lib/iframeLoader.js'], dest: 'dest/js/lib/iframeLoader.js'},
{expand: true, src: ['img/**'], cwd: 'src/', dest: 'dest/', filter: 'isFile'},
{expand: true, src: ['**/*.html'], cwd: 'src/', dest: 'dest/', filter: 'isFile'}
]
}
},
closureCompiler: { closureCompiler: {
options: { options: {
// [REQUIRED] Path to closure compiler // [REQUIRED] Path to closure compiler
@ -161,7 +175,9 @@ module.exports = function(grunt) {
src: ['src/css/**/*.css'] src: ['src/css/**/*.css']
}); });
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-uglify');
@ -173,18 +189,18 @@ module.exports = function(grunt) {
grunt.registerTask('lint', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint']); grunt.registerTask('lint', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint']);
// Validate & Test // Validate & Test
grunt.registerTask('test', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint', 'compile', 'connect:test', 'ghost:default']); grunt.registerTask('test', ['lint', 'compile', 'connect:test', 'ghost:default']);
// Validate & Test (faster version) will NOT work on travis !! // Validate & Test (faster version) will NOT work on travis !!
grunt.registerTask('precommit', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint', 'compile', 'connect:test', 'ghost:local']); grunt.registerTask('precommit', ['lint', 'compile', 'connect:test', 'ghost:local']);
// Compile JS code (eg verify JSDoc annotation and types, no actual minified code generated). // Compile JS code (eg verify JSDoc annotation and types, no actual minified code generated).
grunt.registerTask('compile', ['closureCompiler:compile']); grunt.registerTask('compile', ['closureCompiler:compile', 'clean:after']);
grunt.registerTask('merge', ['concat:js', 'concat:css', 'uglify']); grunt.registerTask('merge', ['concat:js', 'concat:css', 'uglify', 'copy']);
// Validate & Build // Validate & Build
grunt.registerTask('default', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint', 'concat:js', 'concat:css', 'compile', 'uglify']); grunt.registerTask('default', ['clean:before', 'lint', 'compile', 'merge']);
// Start webserver // Start webserver
grunt.registerTask('serve', ['connect:serve']); grunt.registerTask('serve', ['connect:serve']);

View file

@ -13,8 +13,10 @@
}, },
"devDependencies": { "devDependencies": {
"grunt": "~0.4.1", "grunt": "~0.4.1",
"grunt-contrib-clean": "0.5.0",
"grunt-contrib-connect": "0.3.0", "grunt-contrib-connect": "0.3.0",
"grunt-contrib-concat": "0.1.2", "grunt-contrib-concat": "0.1.2",
"grunt-contrib-copy": "0.5.0",
"grunt-contrib-jshint": "0.5.4", "grunt-contrib-jshint": "0.5.4",
"grunt-contrib-uglify": "0.2.2", "grunt-contrib-uglify": "0.2.2",
"grunt-ghost": "1.0.12", "grunt-ghost": "1.0.12",

View file

@ -59,11 +59,11 @@
} else { } else {
var script; var script;
if (window.location.href.indexOf("pack") != -1) { if (window.location.href.indexOf("pack") != -1) {
script = "build/piskel-packaged.js"; script = "js/piskel-packaged.js";
} else { } else {
script = "build/piskel-packaged-min.js"; script = "js/piskel-packaged-min.js";
} }
loadStyle('build/piskel-style-packaged.css'); loadStyle('css/piskel-style-packaged.css');
var loaderInterval = window.setInterval(function () { var loaderInterval = window.setInterval(function () {
if (document.querySelectorAll("[data-iframe-loader]").length === 0) { if (document.querySelectorAll("[data-iframe-loader]").length === 0) {