openuds/server/templates/admin/Gruntfile.js

429 lines
9.6 KiB
JavaScript
Raw Normal View History

// Generated on 2015-09-21 using
// generator-webapp 1.1.0
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// If you want to recursively match all subfolders, use:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Automatically load required grunt tasks
require('jit-grunt')(grunt, {
useminPrepare: 'grunt-usemin'
});
// Configurable paths
var config = {
app: 'app',
dist: 'dist'
};
// Define the configuration for all the tasks
grunt.initConfig({
// Project settings
config: config,
// Watches files for changes and runs tasks based on the changed files
watch: {
bower: {
files: ['bower.json'],
tasks: ['wiredep']
},
babel: {
2015-09-25 05:55:07 +03:00
// files: ['<%= config.app %>/js/{,*/}*.js'],
files: [],
tasks: ['babel:dist']
},
babelTest: {
2015-09-25 05:55:07 +03:00
// files: ['test/spec/{,*/}*.js'],
files: [],
tasks: ['babel:test', 'test:watch']
},
gruntfile: {
files: ['Gruntfile.js']
},
sass: {
2015-09-25 05:55:07 +03:00
files: ['<%= config.app %>/css/{,*/}*.{scss,sass}'],
tasks: ['sass', 'postcss']
},
2015-09-25 05:55:07 +03:00
css: {
files: ['<%= config.app %>/css/{,*/}*.css'],
tasks: ['newer:copy:css', 'postcss']
}
},
browserSync: {
options: {
notify: false,
background: true,
watchOptions: {
ignored: ''
}
},
livereload: {
options: {
files: [
'<%= config.app %>/{,*/}*.html',
2015-09-25 05:55:07 +03:00
'.tmp/css/{,*/}*.css',
'<%= config.app %>/img/{,*/}*',
'.tmp/js/{,*/}*.js'
],
port: 9000,
server: {
baseDir: ['.tmp', config.app],
routes: {
'/bower_components': './bower_components'
}
}
}
},
test: {
options: {
port: 9001,
open: false,
logLevel: 'silent',
host: 'localhost',
server: {
baseDir: ['.tmp', './test', config.app],
routes: {
'/bower_components': './bower_components'
}
}
}
},
dist: {
options: {
background: false,
server: '<%= config.dist %>'
}
}
},
// Empties folders to start fresh
clean: {
dist: {
files: [{
dot: true,
src: [
'.tmp',
'<%= config.dist %>/*',
'!<%= config.dist %>/.git*'
]
}]
},
server: '.tmp'
},
2015-09-25 05:55:07 +03:00
// Make sure code css are up to par and there are no obvious mistakes
eslint: {
target: [
'Gruntfile.js',
2015-09-25 05:55:07 +03:00
// '<%= config.app %>/js/{,*/}*.js',
'!<%= config.app %>/js/vendor/*',
'test/spec/{,*/}*.js'
]
},
// Mocha testing framework configuration options
mocha: {
all: {
options: {
run: true,
urls: ['http://<%= browserSync.test.options.host %>:<%= browserSync.test.options.port %>/index.html']
}
}
},
// Compiles ES6 with Babel
babel: {
options: {
sourceMap: true
},
dist: {
files: [{
expand: true,
2015-09-25 05:55:07 +03:00
cwd: '<%= config.app %>/js',
src: '{,*/}*.jss',
dest: '.tmp/js',
ext: '.jss'
}]
},
test: {
files: [{
expand: true,
cwd: 'test/spec',
2015-09-25 05:55:07 +03:00
src: '{,*/}*.jss',
dest: '.tmp/spec',
2015-09-25 05:55:07 +03:00
ext: '.jss'
}]
}
},
// Compiles Sass to CSS and generates necessary files if requested
sass: {
options: {
sourceMap: true,
sourceMapEmbed: true,
sourceMapContents: true,
includePaths: ['.']
},
dist: {
files: [{
expand: true,
2015-09-25 05:55:07 +03:00
cwd: '<%= config.app %>/css',
src: ['*.{scss,sass}'],
2015-09-25 05:55:07 +03:00
dest: '.tmp/css',
ext: '.css'
}]
}
},
postcss: {
options: {
map: true,
processors: [
2015-09-25 05:55:07 +03:00
// Add vendor prefixed css
require('autoprefixer')({
browsers: ['> 1%', 'last 2 versions', 'Firefox ESR']
})
]
},
dist: {
files: [{
expand: true,
2015-09-25 05:55:07 +03:00
cwd: '.tmp/css/',
src: '{,*/}*.css',
2015-09-25 05:55:07 +03:00
dest: '.tmp/css/'
}]
}
},
// Automatically inject Bower components into the HTML file
wiredep: {
app: {
src: ['<%= config.app %>/index.html'],
exclude: ['bootstrap.js'],
ignorePath: /^(\.\.\/)*\.\./
},
sass: {
2015-09-25 05:55:07 +03:00
src: ['<%= config.app %>/css/{,*/}*.{scss,sass}'],
ignorePath: /^(\.\.\/)+/
}
},
// Renames files for browser caching purposes
filerev: {
dist: {
src: [
2015-09-25 05:55:07 +03:00
'<%= config.dist %>/js/{,*/}*.js',
'<%= config.dist %>/css/{,*/}*.css',
'<%= config.dist %>/img/{,*/}*.*',
'<%= config.dist %>/css/fonts/{,*/}*.*',
'<%= config.dist %>/*.{ico,png}'
]
}
},
// Reads HTML for usemin blocks to enable smart builds that automatically
// concat, minify and revision files. Creates configurations in memory so
// additional tasks can operate on them
useminPrepare: {
options: {
dest: '<%= config.dist %>'
},
html: '<%= config.app %>/index.html'
},
// Performs rewrites based on rev and the useminPrepare configuration
usemin: {
options: {
assetsDirs: [
'<%= config.dist %>',
2015-09-25 05:55:07 +03:00
'<%= config.dist %>/img',
'<%= config.dist %>/css'
]
},
html: ['<%= config.dist %>/{,*/}*.html'],
2015-09-25 05:55:07 +03:00
css: ['<%= config.dist %>/css/{,*/}*.css']
},
// The following *-min tasks produce minified files in the dist folder
imagemin: {
dist: {
files: [{
expand: true,
2015-09-25 05:55:07 +03:00
cwd: '<%= config.app %>/img',
src: '{,*/}*.{gif,jpeg,jpg,png}',
2015-09-25 05:55:07 +03:00
dest: '<%= config.dist %>/img'
}]
}
},
svgmin: {
dist: {
files: [{
expand: true,
2015-09-25 05:55:07 +03:00
cwd: '<%= config.app %>/img',
src: '{,*/}*.svg',
2015-09-25 05:55:07 +03:00
dest: '<%= config.dist %>/img'
}]
}
},
htmlmin: {
dist: {
options: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
conservativeCollapse: true,
removeAttributeQuotes: true,
removeCommentsFromCDATA: true,
removeEmptyAttributes: true,
removeOptionalTags: true,
2015-09-25 05:55:07 +03:00
// true would impact css with attribute selectors
removeRedundantAttributes: false,
useShortDoctype: true
},
files: [{
expand: true,
cwd: '<%= config.dist %>',
src: '{,*/}*.html',
dest: '<%= config.dist %>'
}]
}
},
// By default, your `index.html`'s <!-- Usemin block --> will take care
// of minification. These next options are pre-configured if you do not
// wish to use the Usemin blocks.
// cssmin: {
// dist: {
// files: {
2015-09-25 05:55:07 +03:00
// '<%= config.dist %>/css/main.css': [
// '.tmp/css/{,*/}*.css',
// '<%= config.app %>/css/{,*/}*.css'
// ]
// }
// }
// },
// uglify: {
// dist: {
// files: {
2015-09-25 05:55:07 +03:00
// '<%= config.dist %>/js/js.js': [
// '<%= config.dist %>/js/js.js'
// ]
// }
// }
// },
// concat: {
// dist: {}
// },
// Copies remaining files to places other tasks can use
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= config.app %>',
dest: '<%= config.dist %>',
src: [
'*.{ico,png,txt}',
2015-09-25 05:55:07 +03:00
'img/{,*/}*.webp',
'{,*/}*.html',
2015-09-25 05:55:07 +03:00
'css/fonts/{,*/}*.*'
]
}, {
expand: true,
dot: true,
cwd: '.',
src: 'bower_components/bootstrap-sass/assets/fonts/bootstrap/*',
dest: '<%= config.dist %>'
}]
}
},
// Run some tasks in parallel to speed up build process
concurrent: {
server: [
2015-09-25 05:55:07 +03:00
// 'babel:dist',
'sass'
],
test: [
2015-09-25 05:55:07 +03:00
//'babel'
],
dist: [
2015-09-25 05:55:07 +03:00
//'babel',
'sass',
//'imagemin',
//'svgmin'
]
}
});
grunt.registerTask('serve', 'start the server and preview your app', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'browserSync:dist']);
}
grunt.task.run([
'clean:server',
'wiredep',
'concurrent:server',
'postcss',
'browserSync:livereload',
'watch'
]);
});
grunt.registerTask('server', function (target) {
grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
grunt.task.run([target ? ('serve:' + target) : 'serve']);
});
grunt.registerTask('test', function (target) {
if (target !== 'watch') {
grunt.task.run([
'clean:server',
'concurrent:test',
'postcss'
]);
}
grunt.task.run([
'browserSync:test',
'mocha'
]);
});
grunt.registerTask('build', [
'clean:dist',
'wiredep',
'useminPrepare',
'concurrent:dist',
'postcss',
'concat',
'cssmin',
2015-09-22 20:53:56 +03:00
// 'uglify',
2015-09-25 05:55:07 +03:00
'copy:dist'
// 'filerev',
// 'usemin'
// 'htmlmin'
]);
grunt.registerTask('default', [
'newer:eslint',
'test',
'build'
]);
};