当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 41

飞牛天使/yuncms
关闭

forked from 云阿拉丁/yuncms
关闭
 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gulpfile.js 7.00 KB
一键复制 编辑 原始数据 按行查看 历史
jabber 提交于 2017-03-21 16:45 . 添加管理员
'use strict';
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var sourcemaps = require('gulp-sourcemaps');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var minify = require('gulp-minify-css');
var $ = require('gulp-load-plugins')();
var pkg = require('./package.json');
//项目配置文件
var config = {
AUTOPREFIXER_BROWSERS: [
'ie >= 8',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 2.3',
'bb >= 10'
]
};
var dateFormat = 'UTC:yyyy-mm-dd"T"HH:mm:ss Z';
var banner = [
'/*! <%= pkg.name %> v<%= pkg.version %><%=ver%>',
'by yunalading Team',
'<%= pkg.homepage %>',
'(c) ' + $.util.date(Date.now(), 'UTC:yyyy') + ' HTTGO, Inc.',
'<%= pkg.license.type %>',
$.util.date(Date.now(), dateFormat) + ' */ \n'
].join(' | ');
gulp.task('build:core-js', function () {
gulp.src('./frontend/core/js/core.js').pipe(sourcemaps.init()).pipe(browserify()).pipe($.header(banner, {
pkg: pkg,
ver: ''
})).pipe($.plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
})).pipe(jshint()).pipe(uglify()).pipe($.rename({
'suffix': '.min',
'extname': '.js'
})).pipe(sourcemaps.write('./')).pipe(gulp.dest('./public/static/core/js'));
});
gulp.task('build:core-less', function () {
gulp.src('./frontend/core/less/core.less').pipe(sourcemaps.init()).pipe($.header(banner, {
pkg: pkg,
ver: ''
})).pipe($.plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
})).pipe($.less()).pipe($.autoprefixer({browsers: config.AUTOPREFIXER_BROWSERS})).pipe(minify()).pipe($.rename({
'suffix': '.min',
'extname': '.css'
})).pipe(sourcemaps.write('./')).pipe(gulp.dest('./public/static/core/css'));
});
gulp.task('build:admin-js', function () {
gulp.src('./frontend/admin/js/admin.js').pipe(sourcemaps.init()).pipe(browserify()).pipe($.header(banner, {
pkg: pkg,
ver: ''
})).pipe($.plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
})).pipe(jshint()).pipe(uglify()).pipe($.rename({
'suffix': '.min',
'extname': '.js'
})).pipe(sourcemaps.write('./')).pipe(gulp.dest('./public/static/admin/js'));
});
gulp.task('build:admin-less', function () {
gulp.src('./frontend/admin/less/admin.less').pipe(sourcemaps.init()).pipe($.header(banner, {
pkg: pkg,
ver: ''
})).pipe($.plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
})).pipe($.less()).pipe($.autoprefixer({browsers: config.AUTOPREFIXER_BROWSERS})).pipe(minify()).pipe($.rename({
'suffix': '.min',
'extname': '.css'
})).pipe(sourcemaps.write('./')).pipe(gulp.dest('./public/static/admin/css'));
});
gulp.task('build:home-js', function () {
gulp.src('./frontend/home/**/js/home.js').pipe(sourcemaps.init()).pipe(browserify()).pipe($.header(banner, {
pkg: pkg,
ver: ''
})).pipe($.plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
})).pipe(jshint()).pipe(uglify()).pipe($.rename({
'suffix': '.min',
'extname': '.js'
})).pipe(sourcemaps.write('./')).pipe(gulp.dest('./public/static/home'));
});
gulp.task('build:home-less', function () {
gulp.src('./frontend/home/**/less/home.less').pipe(sourcemaps.init()).pipe($.header(banner, {
pkg: pkg,
ver: ''
})).pipe($.plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
})).pipe($.less()).pipe($.autoprefixer({browsers: config.AUTOPREFIXER_BROWSERS})).pipe($.rename(function (path) {
path.dirname = path.dirname.replace('less', 'css');
})).pipe(minify()).pipe($.rename({
'suffix': '.min',
'extname': '.css'
})).pipe(sourcemaps.write('./')).pipe(gulp.dest('./public/static/home'));
});
gulp.task('build:install-js', function () {
gulp.src('./frontend/install/js/install.js').pipe(sourcemaps.init()).pipe(browserify()).pipe($.header(banner, {
pkg: pkg,
ver: ''
})).pipe($.plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
})).pipe(jshint()).pipe(uglify()).pipe($.rename({
'suffix': '.min',
'extname': '.js'
})).pipe(sourcemaps.write('./')).pipe(gulp.dest('./public/static/install/js'));
});
gulp.task('build:install-less', function () {
gulp.src('./frontend/install/less/install.less').pipe(sourcemaps.init()).pipe($.header(banner, {
pkg: pkg,
ver: ''
})).pipe($.plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
})).pipe($.less()).pipe($.autoprefixer({browsers: config.AUTOPREFIXER_BROWSERS})).pipe(minify()).pipe($.rename({
'suffix': '.min',
'extname': '.css'
})).pipe(sourcemaps.write('./')).pipe(gulp.dest('./public/static/install/css'));
});
gulp.task('copy:jquery', function () {
gulp.src('./node_modules/jquery/dist/**/*').pipe(gulp.dest('./public/static/common/jquery'));
});
gulp.task('copy:handlebars', function () {
gulp.src('./node_modules/handlebars/dist/**/*').pipe(gulp.dest('./public/static/common/handlebars'));
});
gulp.task('copy:amazeui', function () {
gulp.src('./node_modules/amazeui/dist/**/*').pipe(gulp.dest('./public/static/common/amazeui'));
});
gulp.task('copy:amazeui-switch', function () {
gulp.src('./node_modules/amazeui-switch/*.js').pipe(gulp.dest('./public/static/common/amazeui-switch/js'));
});
gulp.task('copy:common', ['copy:jquery', 'copy:handlebars', 'copy:amazeui', 'copy:amazeui-switch']);
gulp.task('build', ['build:core-js', 'build:admin-js', 'build:home-js', 'build:install-js', 'build:core-less', 'build:admin-less', 'build:home-less', 'build:install-less']);
gulp.task('watch', function () {
gulp.watch(['./frontend/core/js/**/*.js'], ['build:core-js']);
gulp.watch(['./frontend/core/less/**/*.less'], ['build:core-less']);
gulp.watch(['./frontend/admin/js/**/*.js'], ['build:admin-js']);
gulp.watch(['./frontend/admin/less/**/*.less'], ['build:admin-less']);
gulp.watch(['./frontend/home/**/js/**/*.js'], ['build:home-js']);
gulp.watch(['./frontend/home/**/less/**/*.less'], ['build:home-less']);
gulp.watch(['./frontend/install/js/**/*.js'], ['build:install-js']);
gulp.watch(['./frontend/install/less/**/*.less'], ['build:install-less']);
gulp.watch(['./frontend/common/js/**/*.js'], ['build:core-js', 'build:install-js', 'build:admin-js', 'build:home-js']);
gulp.watch(['./frontend/common/less/**/*.less'], ['build:core-less', 'build:install-less', 'build:admin-less', 'build:home-less']);
});
gulp.task('default', ['copy:common', 'build', 'watch']);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/potatozhi/yuncms.git
git@gitee.com:potatozhi/yuncms.git
potatozhi
yuncms
yuncms
master

搜索帮助