mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-23 17:34:17 +03:00
429 lines
9.6 KiB
JavaScript
429 lines
9.6 KiB
JavaScript
// 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: {
|
|
// files: ['<%= config.app %>/js/{,*/}*.js'],
|
|
files: [],
|
|
tasks: ['babel:dist']
|
|
},
|
|
babelTest: {
|
|
// files: ['test/spec/{,*/}*.js'],
|
|
files: [],
|
|
tasks: ['babel:test', 'test:watch']
|
|
},
|
|
gruntfile: {
|
|
files: ['Gruntfile.js']
|
|
},
|
|
sass: {
|
|
files: ['<%= config.app %>/css/{,*/}*.{scss,sass}'],
|
|
tasks: ['sass', 'postcss']
|
|
},
|
|
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',
|
|
'.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'
|
|
},
|
|
|
|
// Make sure code css are up to par and there are no obvious mistakes
|
|
eslint: {
|
|
target: [
|
|
'Gruntfile.js',
|
|
// '<%= 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,
|
|
cwd: '<%= config.app %>/js',
|
|
src: '{,*/}*.jss',
|
|
dest: '.tmp/js',
|
|
ext: '.jss'
|
|
}]
|
|
},
|
|
test: {
|
|
files: [{
|
|
expand: true,
|
|
cwd: 'test/spec',
|
|
src: '{,*/}*.jss',
|
|
dest: '.tmp/spec',
|
|
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,
|
|
cwd: '<%= config.app %>/css',
|
|
src: ['*.{scss,sass}'],
|
|
dest: '.tmp/css',
|
|
ext: '.css'
|
|
}]
|
|
}
|
|
},
|
|
|
|
postcss: {
|
|
options: {
|
|
map: true,
|
|
processors: [
|
|
// Add vendor prefixed css
|
|
require('autoprefixer')({
|
|
browsers: ['> 1%', 'last 2 versions', 'Firefox ESR']
|
|
})
|
|
]
|
|
},
|
|
dist: {
|
|
files: [{
|
|
expand: true,
|
|
cwd: '.tmp/css/',
|
|
src: '{,*/}*.css',
|
|
dest: '.tmp/css/'
|
|
}]
|
|
}
|
|
},
|
|
|
|
// Automatically inject Bower components into the HTML file
|
|
wiredep: {
|
|
app: {
|
|
src: ['<%= config.app %>/index.html'],
|
|
exclude: ['bootstrap.js'],
|
|
ignorePath: /^(\.\.\/)*\.\./
|
|
},
|
|
sass: {
|
|
src: ['<%= config.app %>/css/{,*/}*.{scss,sass}'],
|
|
ignorePath: /^(\.\.\/)+/
|
|
}
|
|
},
|
|
|
|
// Renames files for browser caching purposes
|
|
filerev: {
|
|
dist: {
|
|
src: [
|
|
'<%= 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 %>',
|
|
'<%= config.dist %>/img',
|
|
'<%= config.dist %>/css'
|
|
]
|
|
},
|
|
html: ['<%= config.dist %>/{,*/}*.html'],
|
|
css: ['<%= config.dist %>/css/{,*/}*.css']
|
|
},
|
|
|
|
// The following *-min tasks produce minified files in the dist folder
|
|
imagemin: {
|
|
dist: {
|
|
files: [{
|
|
expand: true,
|
|
cwd: '<%= config.app %>/img',
|
|
src: '{,*/}*.{gif,jpeg,jpg,png}',
|
|
dest: '<%= config.dist %>/img'
|
|
}]
|
|
}
|
|
},
|
|
|
|
svgmin: {
|
|
dist: {
|
|
files: [{
|
|
expand: true,
|
|
cwd: '<%= config.app %>/img',
|
|
src: '{,*/}*.svg',
|
|
dest: '<%= config.dist %>/img'
|
|
}]
|
|
}
|
|
},
|
|
|
|
htmlmin: {
|
|
dist: {
|
|
options: {
|
|
collapseBooleanAttributes: true,
|
|
collapseWhitespace: true,
|
|
conservativeCollapse: true,
|
|
removeAttributeQuotes: true,
|
|
removeCommentsFromCDATA: true,
|
|
removeEmptyAttributes: true,
|
|
removeOptionalTags: true,
|
|
// 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: {
|
|
// '<%= config.dist %>/css/main.css': [
|
|
// '.tmp/css/{,*/}*.css',
|
|
// '<%= config.app %>/css/{,*/}*.css'
|
|
// ]
|
|
// }
|
|
// }
|
|
// },
|
|
// uglify: {
|
|
// dist: {
|
|
// files: {
|
|
// '<%= 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}',
|
|
'img/{,*/}*.webp',
|
|
'{,*/}*.html',
|
|
'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: [
|
|
// 'babel:dist',
|
|
'sass'
|
|
],
|
|
test: [
|
|
//'babel'
|
|
],
|
|
dist: [
|
|
//'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',
|
|
// 'uglify',
|
|
'copy:dist'
|
|
// 'filerev',
|
|
// 'usemin'
|
|
// 'htmlmin'
|
|
]);
|
|
|
|
grunt.registerTask('default', [
|
|
'newer:eslint',
|
|
'test',
|
|
'build'
|
|
]);
|
|
};
|