Use string-replace and copy partials over

This commit is contained in:
Joao Mesquita 2015-08-21 19:12:28 -03:00
parent 147a639499
commit d825ad8a76
4 changed files with 79 additions and 53 deletions

View File

@ -20,7 +20,7 @@ module.exports = function (grunt) {
dist: 'dist' dist: 'dist'
}; };
var ip = grunt.option('ip') || 'localhost'; var ip = grunt.option('ip');
// Project configuration. // Project configuration.
grunt.initConfig({ grunt.initConfig({
@ -35,7 +35,7 @@ module.exports = function (grunt) {
}, },
js: { js: {
files: ['js/verto-service.js'], files: ['js/verto-service.js'],
tasks: ['includereplace:dev'] tasks: ['string-replace:dev']
}, },
styles: { styles: {
files: ['<%= config.app %>/css/{,*/}*.css'], files: ['<%= config.app %>/css/{,*/}*.css'],
@ -47,25 +47,20 @@ module.exports = function (grunt) {
}, },
// Replace so we can have it properly passed from dev // Replace so we can have it properly passed from dev
includereplace: { 'string-replace': {
dev: { dev: {
options: { files: {
globals: { '.tmp/js/verto-service.js': '<%= config.app %>/js/verto-service.js'
ip: ip
},
}, },
src: 'js/verto-service.js',
dest: '.tmp/js/verto-service.js'
},
prod: {
options: { options: {
globals: { replacements: [
ip: ip {
}, pattern: 'window.location.hostname',
}, replacement: ip
src: 'js/verto-service.js', }
dest: 'dist/js/' ]
} }
}
}, },
wiredep: { wiredep: {
app: { app: {
@ -87,9 +82,9 @@ module.exports = function (grunt) {
dist: { dist: {
files: [{ files: [{
expand: true, expand: true,
cwd: '.tmp/styles/', cwd: '.tmp/css/',
src: '{,*/}*.css', src: '{,*/}*.css',
dest: '.tmp/styles/' dest: '.tmp/css/'
}] }]
} }
}, },
@ -120,6 +115,15 @@ module.exports = function (grunt) {
} }
} }
}, },
dist: {
options: {
port: 9001,
background: false,
server: {
baseDir: ['dist']
}
}
}
}, },
jshint: { jshint: {
@ -206,28 +210,34 @@ module.exports = function (grunt) {
} }
}, },
htmlmin: { // htmlmin: {
dist: { // dist: {
options: { // options: {
collapseBooleanAttributes: true, // collapseBooleanAttributes: true,
collapseWhitespace: true, // collapseWhitespace: true,
conservativeCollapse: true, // conservativeCollapse: true,
removeAttributeQuotes: true, // removeAttributeQuotes: true,
removeCommentsFromCDATA: true, // removeCommentsFromCDATA: true,
removeEmptyAttributes: true, // removeEmptyAttributes: true,
removeOptionalTags: true, // removeOptionalTags: true,
// true would impact styles with attribute selectors // // true would impact styles with attribute selectors
removeRedundantAttributes: false, // removeRedundantAttributes: false,
useShortDoctype: true // useShortDoctype: true
}, // },
files: [{ // files: [{
expand: true, // expand: true,
cwd: '<%= config.dist %>', // cwd: '<%= config.dist %>',
src: '{,*/}*.html', // src: '{,*/}*.html',
dest: '<%= config.dist %>' // dest: '<%= config.dist %>'
}] // },
} // {
}, // expand: true,
// cwd: '<%= config.dist %>/partials',
// src: '{,*/}*.html',
// dest: '<%= config.dist %>/partials'
// }]
// }
// },
// ng-annotate tries to make the code safe for minification automatically // ng-annotate tries to make the code safe for minification automatically
// by using the Angular long form for dependency injection. // by using the Angular long form for dependency injection.
ngAnnotate: { ngAnnotate: {
@ -251,6 +261,7 @@ module.exports = function (grunt) {
src: [ src: [
'*.{ico,png,txt}', '*.{ico,png,txt}',
'*.html', '*.html',
'partials/**/*.html',
'images/{,*/}*.{webp}', 'images/{,*/}*.{webp}',
'css/fonts/{,*/}*.*' 'css/fonts/{,*/}*.*'
] ]
@ -264,6 +275,11 @@ module.exports = function (grunt) {
cwd: 'bower_components/bootstrap/dist', cwd: 'bower_components/bootstrap/dist',
src: 'fonts/*', src: 'fonts/*',
dest: 'dist' dest: 'dist'
}, {
expand: true,
cwd: 'bower_components/bootstrap-material-design/dist',
src: 'fonts/*',
dest: 'dist'
}] }]
}, },
styles: { styles: {
@ -286,13 +302,23 @@ module.exports = function (grunt) {
}, },
}); });
grunt.registerTask('serve', ['clean:server', grunt.registerTask('serve', function (target) {
var tasks = ['clean:server',
'wiredep', 'wiredep',
'concurrent:server', 'concurrent:server',
'postcss', 'postcss'];
'includereplace:dev',
if (ip) {
tasks = tasks.concat(['string-replace:dev',
'browserSync:livereload', 'browserSync:livereload',
'watch']); 'watch']);
} else {
tasks = tasks.concat(['browserSync:livereload',
'watch']);
}
grunt.task.run(tasks);
});
grunt.registerTask('build', [ grunt.registerTask('build', [
'clean:dist', 'clean:dist',
@ -307,7 +333,7 @@ module.exports = function (grunt) {
'copy:dist', 'copy:dist',
'filerev', 'filerev',
'usemin', 'usemin',
'htmlmin' // 'htmlmin'
]); ]);
}; };

View File

@ -23,7 +23,7 @@
<!-- endbuild --> <!-- endbuild -->
<!-- CSS --> <!-- CSS -->
<!-- build:css(.tmp) css/main.css --> <!-- build:css(.) css/verto.css -->
<link rel="stylesheet" type="text/css" href="css/verto.css"> <link rel="stylesheet" type="text/css" href="css/verto.css">
<!-- endbuild --> <!-- endbuild -->

View File

@ -117,8 +117,8 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
textTo: $cookieStore.get('verto_demo_textto') || "1000", textTo: $cookieStore.get('verto_demo_textto') || "1000",
login: $cookieStore.get('verto_demo_login') || "1008", login: $cookieStore.get('verto_demo_login') || "1008",
password: $cookieStore.get('verto_demo_passwd') || "1234", password: $cookieStore.get('verto_demo_passwd') || "1234",
hostname: $cookieStore.get('verto_demo_hostname') || '@@ip', hostname: $cookieStore.get('verto_demo_hostname') || window.location.hostname,
wsURL: $cookieStore.get('verto_demo_wsurl') || ("wss://" + '@@ip' + ":8082"), wsURL: $cookieStore.get('verto_demo_wsurl') || ("wss://" + window.location.hostname + ":8082"),
useVideo: $cookieStore.get('verto_demo_vid_checked') || true, useVideo: $cookieStore.get('verto_demo_vid_checked') || true,
useCamera: $cookieStore.get('verto_demo_camera_checked') || true, useCamera: $cookieStore.get('verto_demo_camera_checked') || true,
useStereo: $cookieStore.get('verto_demo_stereo_checked') || true, useStereo: $cookieStore.get('verto_demo_stereo_checked') || true,

View File

@ -3,10 +3,10 @@
"version": "0.0.1", "version": "0.0.1",
"description": "HTML5 Based Communications application for use with FreeSWITCH and mod_verto", "description": "HTML5 Based Communications application for use with FreeSWITCH and mod_verto",
"devDependencies": { "devDependencies": {
"grunt-browser-sync": "^2.1.2",
"browser-sync": "^2.8.2",
"autoprefixer-core": "^5.2.1", "autoprefixer-core": "^5.2.1",
"browser-sync": "^2.8.2",
"grunt": "^0.4.5", "grunt": "^0.4.5",
"grunt-browser-sync": "^2.1.2",
"grunt-concurrent": "^1.0.0", "grunt-concurrent": "^1.0.0",
"grunt-contrib-clean": "^0.6.0", "grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.5.0", "grunt-contrib-concat": "^0.5.0",
@ -15,13 +15,13 @@
"grunt-contrib-htmlmin": "^0.4.0", "grunt-contrib-htmlmin": "^0.4.0",
"grunt-contrib-imagemin": "^0.9.2", "grunt-contrib-imagemin": "^0.9.2",
"grunt-contrib-jshint": "^0.11.0", "grunt-contrib-jshint": "^0.11.0",
"grunt-postcss": "^0.5.3",
"grunt-contrib-uglify": "^0.7.0", "grunt-contrib-uglify": "^0.7.0",
"grunt-contrib-watch": "latest", "grunt-contrib-watch": "latest",
"grunt-filerev": "^2.1.2", "grunt-filerev": "^2.1.2",
"grunt-include-replace": "^3.1.0",
"grunt-newer": "^1.1.0", "grunt-newer": "^1.1.0",
"grunt-ng-annotate": "^0.9.2", "grunt-ng-annotate": "^0.9.2",
"grunt-postcss": "^0.5.3",
"grunt-string-replace": "^1.2.0",
"grunt-svgmin": "^2.0.0", "grunt-svgmin": "^2.0.0",
"grunt-usemin": "^3.0.0", "grunt-usemin": "^3.0.0",
"grunt-wiredep": "^2.0.0", "grunt-wiredep": "^2.0.0",