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

View File

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

View File

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

View File

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