1 Star 0 Fork 112

高雷/thinker-md

forked from 邓海二/thinker-md 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Gruntfile.js 7.18 KB
一键复制 编辑 原始数据 按行查看 历史
beyondl 提交于 2015-03-20 15:13 . 重新打包
module.exports = function (grunt) {
"use strict";
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
// define a string to put between each file in the concatenated output
//separator: ';',
// Replace all 'use strict' statements in the code
process: function (src, filepath) {
return '// Source: ' + filepath + '\n' +
src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
}
},
dist: {
// the files to concatenate
src: [
/*highlight*/
'<%= pkg.dir.js.vendor %>highlight/highlight.js',
/*bootstrap*/
'<%= pkg.dir.js.vendor %>bootstrap/bootstrap.js',
/*markdown*/
'<%= pkg.dir.js.vendor %>markdown/he.js',
'<%= pkg.dir.js.vendor %>markdown/marked.js',
'<%= pkg.dir.js.vendor %>markdown/to-markdown.js',
'<%= pkg.dir.js.vendor %>markdown/jsHtmlToText.js',
'<%= pkg.dir.js.vendor %>markdown/undo.js',
'<%= pkg.dir.js.vendor %>markdown/tab.js',
'<%= pkg.dir.js.vendor %>markdown/config.js',
'<%= pkg.dir.js.vendor %>markdown/bootstrap-markdown.js',
'<%= pkg.dir.js.vendor %>markdown/locale/*.js'
],
// the location of the resulting JS file
dest: 'dist/javascripts/vendor/<%= pkg.name %>.js'
},
user: {
// the files to concatenate
src: ['<%= pkg.dir.js.user %>*.js', '<%= pkg.dir.js.user %>**/*.js'],
// the location of the resulting JS file
dest: 'dist/javascripts/user/<%= pkg.name %>-user.js'
}
},
uglify: {
options: {
// the banner is inserted at the top of the output
//不混淆变量名
mangle: {
except: ['jquery', 'marked', 'toMarkdown', 'markdown', 'htmlToText', 'hljs', 'Undo']
},
preserveComments: false,
sourceMap: true,
//输出压缩率,可选的值有 false(不输出信息),gzip
report: "min",
ASCIIOnly: 'true',
beautify: {
"ascii_only": true
},
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */',
compress: {
drop_console: true,
"hoist_funs": false,
loops: false,
unused: false
}
},
dist: {
options: {
sourceMapName: "dist/javascripts/vendor/<%= pkg.name %>.min.map"
},
files: {
'dist/javascripts/vendor/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
}
},
user: {
options: {
sourceMapName: "dist/javascripts/user/<%= pkg.name %>-user.min.map"
},
files: {
'dist/javascripts/user/<%= pkg.name %>-user.min.js': ['<%= concat.user.dest %>']
}
}
},
cssmin: {
options: {
keepSpecialComments: 0,
report: 'gzip'
},
dist: {
files: {
'dist/stylesheets/vendor/<%= pkg.name %>.min.css': [
'<%= pkg.dir.css.vendor %>*.css',
'<%= pkg.dir.css.vendor %>**/*.css',
'<%= pkg.dir.css.vendor %>**/**/*.css'
]
}
},
user: {
files: {
'dist/stylesheets/user/<%= pkg.name %>.user.min.css': [
'<%= pkg.dir.css.user %>*.css',
'<%= pkg.dir.css.user %>**/*.css',
'<%= pkg.dir.css.user %>**/**/*.css'
]
}
}
},
copy: {
lib: {
expand: true,
cwd: '<%= pkg.dir.js.vendor %>jquery/',
src: [
'*.js'
], dest: 'dist/javascripts/vendor/'
},
fonts: {
files: [
{
expand: true,
cwd: '<%= pkg.dir.fonts%>',
src: [
'*.eot',
'*.svg',
'*.ttf',
'*.woff',
'*.woff2'
],
dest: 'dist/stylesheets/fonts/'
}
]
},
img: {
files: [
{
expand: true,
cwd: '<%= pkg.dir.img%>',
src: [
'*.*',
'**/*.*',
'**/**/*.*'
],
dest: 'dist/stylesheets/img/'
}
]
}
},
watch: {
jsuser: {
files: [
'<%= pkg.dir.js.user %>*.js',
'<%= pkg.dir.js.user %>**/*.js',
'<%= pkg.dir.js.user %>**/**/*.js'
],
tasks: ['concat:user', 'uglify:user']
},
jsvendor: {
files: [
'<%= pkg.dir.js.vendor %>*.js',
'<%= pkg.dir.js.vendor %>**/*.js',
'<%= pkg.dir.js.vendor %>**/**/*.js'
],
tasks: ['concat:dist', 'uglify:dist']
},
cssuser: {
files: [
'<%= pkg.dir.css.user %>*.css',
'<%= pkg.dir.css.user %>**/*.css',
'<%= pkg.dir.css.user %>**/**/*.css'
],
tasks: ['cssmin:user']
},
cssvendor: {
files: [
'<%= pkg.dir.css.vendor %>*.css',
'<%= pkg.dir.css.vendor %>**/*.css',
'<%= pkg.dir.css.vendor %>**/**/*.css'
],
tasks: ['cssmin:dist']
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('resource', ['copy']);
// the default task can be run just by typing "grunt" on the command line
grunt.registerTask('default', ['concat:dist', 'concat:user', 'uglify:dist', 'uglify:user']);
grunt.registerTask('css', ['cssmin:dist', 'cssmin:user']);
grunt.task.run(['resource', 'default', 'css'])
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gaollg/thinker-md.git
git@gitee.com:gaollg/thinker-md.git
gaollg
thinker-md
thinker-md
master

搜索帮助