mirror of
https://github.com/zhigang1992/m.combee.co.git
synced 2026-01-12 16:32:50 +08:00
429 lines
13 KiB
JavaScript
429 lines
13 KiB
JavaScript
// Generated on 2013-12-15 using generator-webapp 0.4.4
|
|
'use strict';
|
|
|
|
// # 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'
|
|
|
|
module.exports = function (grunt) {
|
|
// show elapsed time at the end
|
|
require('time-grunt')(grunt);
|
|
// load all grunt tasks
|
|
require('load-grunt-tasks')(grunt);
|
|
|
|
grunt.initConfig({
|
|
// configurable paths
|
|
yeoman: {
|
|
app: 'app',
|
|
dist: 'dist'
|
|
},
|
|
watch: {
|
|
compass: {
|
|
files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
|
|
tasks: ['compass:server', 'autoprefixer']
|
|
},
|
|
styles: {
|
|
files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
|
|
tasks: ['copy:styles', 'autoprefixer']
|
|
},
|
|
livereload: {
|
|
options: {
|
|
livereload: '<%= connect.options.livereload %>'
|
|
},
|
|
files: [
|
|
'<%= yeoman.app %>/*.html',
|
|
'.tmp/styles/{,*/}*.css',
|
|
'{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.{js, html}',
|
|
'<%= yeoman.app %>/images/{,*/}*.{gif,jpeg,jpg,png,svg,webp}'
|
|
]
|
|
}
|
|
},
|
|
connect: {
|
|
options: {
|
|
port: 9000,
|
|
livereload: 35729,
|
|
// change this to '0.0.0.0' to access the server from outside
|
|
hostname: '0.0.0.0'
|
|
},
|
|
livereload: {
|
|
options: {
|
|
open: true,
|
|
base: [
|
|
'.tmp',
|
|
'<%= yeoman.app %>'
|
|
],
|
|
middleware: function (connect, options) {
|
|
var middlewares = [];
|
|
var directory = options.directory || options.base[options.base.length - 1];
|
|
if (!Array.isArray(options.base)) {
|
|
options.base = [options.base];
|
|
}
|
|
options.base.forEach(function(base) {
|
|
// Serve static files.
|
|
middlewares.push(connect.static(base));
|
|
});
|
|
|
|
// Setup the proxy
|
|
middlewares.push(require('grunt-connect-proxy/lib/utils').proxyRequest);
|
|
|
|
// Make directory browse-able.
|
|
middlewares.push(connect.directory(directory));
|
|
|
|
return middlewares;
|
|
}
|
|
}
|
|
},
|
|
test: {
|
|
options: {
|
|
base: [
|
|
'.tmp',
|
|
'test',
|
|
'<%= yeoman.app %>'
|
|
]
|
|
}
|
|
},
|
|
dist: {
|
|
options: {
|
|
open: true,
|
|
base: '<%= yeoman.dist %>',
|
|
livereload: false
|
|
}
|
|
},
|
|
server: {
|
|
proxies: [
|
|
{
|
|
context: '/api/v1',
|
|
host: 'combee.co',
|
|
port: 80,
|
|
https: false,
|
|
changeOrigin: true,
|
|
xforward: true
|
|
},
|
|
{
|
|
context: '/assets',
|
|
host: 'combee.co',
|
|
port: 80,
|
|
https: false,
|
|
changeOrigin: true,
|
|
xforward: true
|
|
},
|
|
{
|
|
context: '/uploads',
|
|
host: 'combee.co',
|
|
port: 80,
|
|
https: false,
|
|
changeOrigin: true,
|
|
xforward: true
|
|
},
|
|
{
|
|
context: '/attachments',
|
|
host: 'combee.co',
|
|
port: 80,
|
|
https: false,
|
|
changeOrigin: true,
|
|
xforward: true
|
|
}
|
|
]
|
|
}
|
|
|
|
},
|
|
clean: {
|
|
dist: {
|
|
files: [{
|
|
dot: true,
|
|
src: [
|
|
'.tmp',
|
|
'<%= yeoman.dist %>/*',
|
|
'!<%= yeoman.dist %>/.git*'
|
|
]
|
|
}]
|
|
},
|
|
server: '.tmp'
|
|
},
|
|
jshint: {
|
|
options: {
|
|
jshintrc: '.jshintrc',
|
|
reporter: require('jshint-stylish')
|
|
},
|
|
all: [
|
|
'Gruntfile.js',
|
|
'<%= yeoman.app %>/scripts/{,*/}*.js',
|
|
'!<%= yeoman.app %>/scripts/vendor/*',
|
|
'test/spec/{,*/}*.js'
|
|
]
|
|
},
|
|
mocha: {
|
|
all: {
|
|
options: {
|
|
run: true,
|
|
urls: ['http://<%= connect.test.options.hostname %>:<%= connect.test.options.port %>/index.html']
|
|
}
|
|
}
|
|
},
|
|
compass: {
|
|
options: {
|
|
sassDir: '<%= yeoman.app %>/styles',
|
|
cssDir: '.tmp/styles',
|
|
generatedImagesDir: '.tmp/images/generated',
|
|
imagesDir: '<%= yeoman.app %>/images',
|
|
javascriptsDir: '<%= yeoman.app %>/scripts',
|
|
fontsDir: '<%= yeoman.app %>/styles/fonts',
|
|
importPath: '<%= yeoman.app %>/bower_components',
|
|
httpImagesPath: '/images',
|
|
httpGeneratedImagesPath: '/images/generated',
|
|
httpFontsPath: '/styles/fonts',
|
|
relativeAssets: false,
|
|
assetCacheBuster: true
|
|
},
|
|
dist: {
|
|
options: {
|
|
cssDir: '<%= yeoman.dist %>/styles',
|
|
noLineComment: true,
|
|
outputStyle: 'compressed',
|
|
force: true,
|
|
generatedImagesDir: '<%= yeoman.dist %>/images/generated',
|
|
environment: 'production'
|
|
}
|
|
},
|
|
server: {
|
|
options: {
|
|
debugInfo: true
|
|
}
|
|
}
|
|
},
|
|
autoprefixer: {
|
|
options: {
|
|
browsers: ['last 1 version']
|
|
},
|
|
dist: {
|
|
files: [{
|
|
expand: true,
|
|
cwd: '.tmp/styles/',
|
|
src: '{,*/}*.css',
|
|
dest: '.tmp/styles/'
|
|
}]
|
|
}
|
|
},
|
|
// not used since Uglify task does concat,
|
|
// but still available if needed
|
|
/*concat: {
|
|
dist: {}
|
|
},*/
|
|
// not enabled since usemin task does concat and uglify
|
|
// check index.html to edit your build targets
|
|
// enable this task if you prefer defining your build targets here
|
|
/*uglify: {
|
|
dist: {}
|
|
},*/
|
|
'bower-install': {
|
|
app: {
|
|
html: '<%= yeoman.app %>/index.html',
|
|
ignorePath: '<%= yeoman.app %>/'
|
|
}
|
|
},
|
|
rev: {
|
|
dist: {
|
|
files: {
|
|
src: [
|
|
'<%= yeoman.dist %>/scripts/{,*/}*.js',
|
|
'<%= yeoman.dist %>/styles/{,*/}*.css',
|
|
'<%= yeoman.dist %>/images/{,*/}*.{gif,jpeg,jpg,png,webp}',
|
|
'<%= yeoman.dist %>/styles/fonts/{,*/}*.*'
|
|
]
|
|
}
|
|
}
|
|
},
|
|
useminPrepare: {
|
|
options: {
|
|
dest: '<%= yeoman.dist %>'
|
|
},
|
|
html: '<%= yeoman.app %>/index.html'
|
|
},
|
|
usemin: {
|
|
options: {
|
|
assetsDirs: ['<%= yeoman.dist %>']
|
|
},
|
|
html: ['<%= yeoman.dist %>/{,*/}*.html'],
|
|
css: ['<%= yeoman.dist %>/styles/{,*/}*.css']
|
|
},
|
|
imagemin: {
|
|
dist: {
|
|
files: [{
|
|
expand: true,
|
|
cwd: '<%= yeoman.app %>/images',
|
|
src: '{,*/}*.{gif,jpeg,jpg,png}',
|
|
dest: '<%= yeoman.dist %>/images'
|
|
}]
|
|
}
|
|
},
|
|
svgmin: {
|
|
dist: {
|
|
files: [{
|
|
expand: true,
|
|
cwd: '<%= yeoman.app %>/images',
|
|
src: '{,*/}*.svg',
|
|
dest: '<%= yeoman.dist %>/images'
|
|
}]
|
|
}
|
|
},
|
|
cssmin: {
|
|
// This task is pre-configured if you do not wish to use Usemin
|
|
// blocks for your CSS. By default, the Usemin block from your
|
|
// `index.html` will take care of minification, e.g.
|
|
//
|
|
// <!-- build:css({.tmp,app}) styles/main.css -->
|
|
//
|
|
// dist: {
|
|
// files: {
|
|
// '<%= yeoman.dist %>/styles/main.css': [
|
|
// '.tmp/styles/{,*/}*.css',
|
|
// '<%= yeoman.app %>/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: '<%= yeoman.app %>',
|
|
src: '*.html',
|
|
dest: '<%= yeoman.dist %>'
|
|
}]
|
|
}
|
|
},
|
|
// Put files not handled in other tasks here
|
|
copy: {
|
|
dist: {
|
|
files: [{
|
|
expand: true,
|
|
dot: true,
|
|
cwd: '<%= yeoman.app %>',
|
|
dest: '<%= yeoman.dist %>',
|
|
src: [
|
|
'*.{ico,png,txt}',
|
|
'.htaccess',
|
|
'images/{,*/}*.{webp,gif}',
|
|
'styles/fonts/{,*/}*.*',
|
|
'bower_components/sass-bootstrap/fonts/*.*'
|
|
]
|
|
}]
|
|
},
|
|
styles: {
|
|
expand: true,
|
|
dot: true,
|
|
cwd: '<%= yeoman.app %>/styles',
|
|
dest: '.tmp/styles/',
|
|
src: '{,*/}*.css'
|
|
}
|
|
},
|
|
modernizr: {
|
|
devFile: '<%= yeoman.app %>/bower_components/modernizr/modernizr.js',
|
|
outputFile: '<%= yeoman.dist %>/bower_components/modernizr/modernizr.js',
|
|
files: [
|
|
'<%= yeoman.dist %>/scripts/{,*/}*.js',
|
|
'<%= yeoman.dist %>/styles/{,*/}*.css',
|
|
'!<%= yeoman.dist %>/scripts/vendor/*'
|
|
],
|
|
uglify: true
|
|
},
|
|
concurrent: {
|
|
server: [
|
|
'compass',
|
|
'copy:styles'
|
|
],
|
|
test: [
|
|
'copy:styles'
|
|
],
|
|
dist: [
|
|
'compass',
|
|
'copy:styles',
|
|
'imagemin',
|
|
'svgmin',
|
|
'htmlmin'
|
|
]
|
|
},
|
|
requirejs: {
|
|
options: {
|
|
name: "main",
|
|
baseUrl: "<%= yeoman.app %>/scripts",
|
|
mainConfigFile: "<%= yeoman.app %>/scripts/main.js"
|
|
},
|
|
compile: {
|
|
options: {
|
|
out: "<%= yeoman.tmp %>/scripts/main.js"
|
|
}
|
|
},
|
|
dist: {
|
|
options: {
|
|
out: "<%= yeoman.dist %>/scripts/main.js"
|
|
}
|
|
}
|
|
}
|
|
});
|
|
grunt.registerTask('dist', [
|
|
'requirejs:dist',
|
|
'compass:dist'
|
|
]),
|
|
grunt.registerTask('serve', function (target) {
|
|
if (target === 'dist') {
|
|
return grunt.task.run(['build', 'connect:dist:keepalive']);
|
|
}
|
|
|
|
grunt.task.run([
|
|
'clean:server',
|
|
'concurrent:server',
|
|
'autoprefixer',
|
|
'configureProxies:server',
|
|
'connect:livereload',
|
|
'watch'
|
|
]);
|
|
});
|
|
|
|
grunt.registerTask('server', function () {
|
|
grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
|
|
grunt.task.run(['serve']);
|
|
});
|
|
|
|
grunt.registerTask('test', [
|
|
'clean:server',
|
|
'concurrent:test',
|
|
'autoprefixer',
|
|
'connect:test',
|
|
'mocha'
|
|
]);
|
|
|
|
grunt.registerTask('build', [
|
|
'clean:dist',
|
|
'useminPrepare',
|
|
'concurrent:dist',
|
|
'autoprefixer',
|
|
'concat',
|
|
'cssmin',
|
|
'uglify',
|
|
'modernizr',
|
|
'copy:dist',
|
|
'rev',
|
|
'usemin'
|
|
]);
|
|
|
|
grunt.registerTask('default', [
|
|
'jshint',
|
|
'test',
|
|
'build'
|
|
]);
|
|
};
|