generator-jangular
Version:
Quickstart a Maven + CDI + TomEE + Jackson + AngularJS project
343 lines (331 loc) • 10.1 kB
JavaScript
// Generated on <%= (new Date).toISOString().split('T')[0] %> using <%= pkg.name %> <%= pkg.version %>
;
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
grunt.initConfig({
yeoman: {
// configurable paths
app: require('./bower.json').appPath || 'app',
dist: 'target/yeoman-dist'
},
watch: {
styles: {
files: ['src/main/web/styles/{,*/}*.css'],
tasks: ['copy:styles', 'autoprefixer']
},
livereload: {
options: {
livereload: 35729
},
files: [
'src/main/web/{,*/}*.html',
'src/main/web/styles/{,*/}*.css',
'{.tmp/,}src/main/web/scripts/{,*/}*.js',
'src/main/web/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
autoprefixer: {
options: ['last 1 version'],
dist: {
files: [{
expand: true,
cwd: '.tmp/styles/',
src: '{,*/}*.css',
dest: '.tmp/styles/'
}]
}
},
connect: {
proxies: [
{
context: '/rest',
host: 'localhost',
port: 8080,
https: false,
changeOrigin: false,
rewrite: {
'rest': '<%= _.slugify(baseName) %>-<%= version %>/rest'
}
}
],
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost',
livereload: 35729
},
livereload: {
options: {
open: true,
base: [
'.tmp',
'src/main/web'
],
middleware: function (connect) {
return [
proxySnippet,
connect.static(require('path').resolve('src/main/web'))
];
}
}
},
test: {
options: {
port: 9001,
base: [
'.tmp',
'test',
'src/main/web'
]
}
},
dist: {
options: {
open: true,
base: '<%%= yeoman.dist %>',
middleware: function (connect) {
return [
proxySnippet,
connect.static(require('path').resolve('target/yeoman-dist'))
];
}
}
}
},
clean: {
dist: {
files: [{
dot: true,
src: [
'.tmp',
'<%%= yeoman.dist %>/*',
'!<%%= yeoman.dist %>/.git*'
]
}]
},
server: '.tmp'
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'src/main/web/scripts/{,*/}*.js'
]
},
// not used since Uglify task does concat,
// but still available if needed
/*concat: {
dist: {}
},*/
rev: {
dist: {
files: {
src: [
'<%%= yeoman.dist %>/scripts/{,*/}*.js',
'<%%= yeoman.dist %>/styles/{,*/}*.css',
'<%%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
'<%%= yeoman.dist %>/styles/fonts/*'
]
}
}
},
useminPrepare: {
html: 'src/main/web/index.html',
options: {
dest: '<%%= yeoman.dist %>'
}
},
usemin: {
html: ['<%%= yeoman.dist %>/{,*/}*.html'],
css: ['<%%= yeoman.dist %>/styles/{,*/}*.css'],
options: {
dirs: ['<%%= yeoman.dist %>']
}
},
imagemin: {
dist: {
files: [{
expand: true,
cwd: 'src/main/web/images',
src: '{,*/}*.{png,jpg,jpeg}',
dest: '<%%= yeoman.dist %>/images'
}]
}
},
svgmin: {
dist: {
files: [{
expand: true,
cwd: 'src/main/web/images',
src: '{,*/}*.svg',
dest: '<%%= yeoman.dist %>/images'
}]
}
},
cssmin: {
// By default, your `index.html` <!-- Usemin Block --> will take care of
// minification. This option is pre-configured if you do not wish to use
// Usemin blocks.
// dist: {
// files: {
// '<%%= yeoman.dist %>/styles/main.css': [
// '.tmp/styles/{,*/}*.css',
// 'styles/{,*/}*.css'
// ]
// }
// }
},
htmlmin: {
dist: {
options: {
/*removeCommentsFromCDATA: true,
// https://github.com/yeoman/grunt-usemin/issues/44
//collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeOptionalTags: true*/
},
files: [{
expand: true,
cwd: 'src/main/web',
src: ['*.html', 'views/*.html'],
dest: '<%%= yeoman.dist %>'
}]
}
},
// Put files not handled in other tasks here
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: 'src/main/web',
dest: '<%%= yeoman.dist %>',
src: [
'*.{ico,png,txt}',
'.htaccess',
'images/{,*/}*.{gif,webp}',
'styles/fonts/*'
]
}, {
expand: true,
cwd: '.tmp/images',
dest: '<%%= yeoman.dist %>/images',
src: [
'generated/*'
]
}, {
expand:true,
flatten: true,
cwd: 'src/main/web',
dest: '<%%= yeoman.dist %>/fonts',
src: [
'bower_components/bootstrap/dist/fonts/*'
]
}]
},
styles: {
expand: true,
cwd: 'src/main/web/styles',
dest: '.tmp/styles/',
src: '{,*/}*.css'
}
},
concurrent: {
server: [
'copy:styles'
],
test: [
'copy:styles'
],
dist: [
'copy:styles',
'imagemin',
'svgmin',
'htmlmin'
]
},
karma: {
unit: {
configFile: 'karma.conf.js',
singleRun: true
}
},
cdnify: {
dist: {
html: ['<%%= yeoman.dist %>/*.html']
}
},
ngmin: {
dist: {
files: [{
expand: true,
cwd: '.tmp',
src: ['**/*.js'],
dest: '.tmp'
}]
}
}/*,
uglify: {
dist: {
files: {
'<%%= yeoman.dist %>/scripts/scripts.js': [
'<%%= yeoman.dist %>/scripts/scripts.js'
]
}
}
} */
});
grunt.registerTask('server', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'configureProxies', 'connect:dist:keepalive']);
}
grunt.task.run([
'clean:server',
'concurrent:server',
'autoprefixer',
'configureProxies',
'connect:livereload',
'watch'
]);
});
grunt.registerTask('test', [
'clean:server',
'concurrent:test',
'autoprefixer',
'connect:test',
'karma'
]);
grunt.registerTask('build', [
'clean:dist',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
'concat',
'copy:dist',
'cdnify',
'ngmin',
'cssmin',
'uglify',
'rev',
'usemin'
]);
grunt.registerTask('default', [
'jshint',
'test',
'build'
]);
};