1 Star 0 Fork 6

kyany/Xminder

forked from gkf35278/Xminder 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Gruntfile.js 6.13 KB
一键复制 编辑 原始数据 按行查看 历史
/*-----------------------------------------------------
* livereload Default Setting
*-----------------------------------------------------*/
'use strict';
var path = require('path');
/*-----------------------------------------------------
* Module Setting
*-----------------------------------------------------*/
module.exports = function(grunt) {
// These plugins provide necessary tasks.
/* [Build plugin & task ] ------------------------------------*/
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-postcss');
grunt.loadNpmTasks('grunt-autoprefixer');
var banner = '/*!\n' +
' * ====================================================\n' +
' * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
' * GitHub: <%= pkg.repository.url %> \n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n' +
' * ====================================================\n' +
' */\n\n';
var packs = ['index', 'edit', 'share', 'm-share'];
var sources = require('./import.js');
var srcPath = 'src/';
var distPath = 'dist/';
var distPages = ['index', 'edit', 'viewshare', 'm-share'].map(function(name) {
return distPath + name + '.html';
});
var concatConfigs = {};
packs.forEach(function(pack) {
concatConfigs[pack] = {
options: {
banner: banner + '(function(window) {\n\n',
footer: '\n\n})(window)',
sourceMap: false,
sourceMapStyle: 'link'
},
src: sources.filter(function(source) {
return source.pack == '*' || source.pack.split('|').indexOf(pack) !== -1;
}).map(function(source) {
return source.path;
}),
dest: distPath + 'kityminder.' + pack + '.js'
};
});
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
clean: ['dist', 'native-support/upload/', 'native-support/src/tmp/'],
concat: concatConfigs,
uglify: {
minimize: {
options: {
banner: banner,
sourceMap: false
},
files: (function() {
var files = {};
packs.forEach(function(pack) {
files[distPath + 'kityminder.' + pack + '.min.js'] = distPath + 'kityminder.' + pack + '.js';
});
return files;
})()
}
},
copy: {
dir: {
files: [{
src: [
'ui/theme/**/css/*.css',
'ui/theme/**/css/*.css.map',
'ui/theme/**/images/*',
'lang/**/*',
'static/**/*',
'native-support/**/*',
'lib/ZeroClipboard.swf',
'lib/inflate.js',
'lib/source-map.min.js',
'index.html',
'edit.html',
'viewshare.html',
'm-share.html',
'download.php'
],
dest: distPath
}]
},
km_config: {
expand: true,
src: 'kityminder.config.js',
dest: distPath
},
mise: {
files: [{
src: ['LICENSE', 'favicon.ico', 'README.md', 'CHANGELOG.md', 'example.xmind'],
dest: distPath
}]
}
},
replace: {
online: {
src: distPages,
overwrite: true,
replacements: [{
from: /import\.js\?pack=([\w-]+)\"/,
to: 'kityminder.$1.min.js"'
}]
},
pageNoCache: {
src: distPages,
overwrite: true,
replacements: [{
from: /(src|href)=\"(.+?)\.(js|css)\"/ig,
to: '$1="$2.$3?_=' + (+new Date()) + '"'
}]
},
imageNoCache: {
src: 'dist/ui/theme/default/css/default.all.css',
overwrite: true,
replacements: [{
from: /\.png/ig,
to: '.png?_=' + (+new Date())
}]
}
},
watch: {
less: {
files: ['ui/theme/**/*.less'],
tasks: ['less:compile', 'autoprefixer']
}
},
less: {
compile: {
files: {
'ui/theme/default/css/default.all.temp.css': [
'ui/theme/default/css/import.less'
]
},
options: {
sourceMap: false,
sourceMapFilename: 'ui/theme/default/css/default.all.temp.css.map',
sourceMapBasepath: 'ui/theme/default/css/'
}
}
},
autoprefixer: {
all: {
options: {
map: true
},
src: 'ui/theme/default/css/default.all.temp.css',
dest: 'ui/theme/default/css/default.all.css'
}
}
});
// Build task(s).
grunt.registerTask('default', ['clean', 'concat', 'uglify', 'less', 'autoprefixer', 'copy', 'replace']);
grunt.registerTask('dev', ['less', 'autoprefixer', 'watch']);
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/kyany/Xminder.git
git@gitee.com:kyany/Xminder.git
kyany
Xminder
Xminder
dev

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385