1 Star 0 Fork 42

君洛羽 / project_22213009

forked from 风情万种 / OscIM 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gulpfile.babel.js 4.71 KB
一键复制 编辑 原始数据 按行查看 历史
风情万种 提交于 2017-08-31 21:00 . - 更新字体为basee64编码引入
import gulp from 'gulp'
import fs from 'fs'
import path from 'path'
import {merge} from 'event-stream'
import map from 'map-stream'
import {spawn} from 'child_process'
const base64 = require('gulp-base64');
const uglify = require('gulp-uglify')
const minify = require('gulp-minify-css')
const $ = require('gulp-load-plugins')()
const config = require('./package.json')
const version = config.version
const name = config.name
const description = config.description
const homepage = config.homepage
// Tasks
gulp.task('clean', () => {
return pipe('./tmp', $.clean())
})
gulp.task('build', (cb) => {
$.runSequence('clean','styles', 'layim', 'chrome', 'firefox', 'opera', cb)
})
gulp.task('styles', () => {
return pipe(
'./src/styles/common.less',
$.plumber(),
$.less({relativeUrls: true}),
$.autoprefixer({cascade: true}),
'./tmp'
)
})
//layim
gulp.task('layim', ['layimjs','layimcss'], () => {
})
gulp.task('layimjs', () => {
const mods = 'laytpl,laypage,laydate,jquery,layer,element,upload,form,tree,util,flow,layedit,code,layim'
const src = [
'./src/layim/**/{layui,all,'+ mods +'}.js'
]
return pipe(
src,
$.babel(),
uglify(),
$.concat('layui.all.js'),
$.preprocess({context: {CHROME: true}}),
'./tmp'
)
})
gulp.task('layimcss', () => {
const css_dir = 'laydate,layer,layim'
const src = [
'./src/layim/css/**/{layui,code,'+ css_dir +'}.css'
]
return pipe(
src,
base64({debug:true}),
minify({compatibility: 'ie8'}),
$.concat('layui.all.css'),
$.preprocess({context: {CHROME: true}}),
'./tmp'
)
})
// Chrome
gulp.task('chrome:js', () => {
return buildJs(['./src/config/chrome/overrides.js'], {CHROME: true})
})
gulp.task('chrome',['chrome:js'], () => {
return merge(
pipe('./icons/**/*', './tmp/chrome/icons'),
pipe(['./tmp/*.css'], './tmp/chrome/css'),
pipe(['./src/layim/images/**/*','./src/layim/css/modules/layim/**/*.jpg'], './tmp/chrome/images'),
pipe(['./tmp/*.js','./libs/*.js'], './tmp/chrome/js'),
pipe('./src/config/chrome/background.js', $.babel(), './tmp/chrome/'),
pipe('./src/config/chrome/manifest.json',
$.replace('$VERSION', version),
$.replace('$NAME', name),
$.replace('$DESCRIPTION', description),
$.replace('$HOMEPAGE', homepage),
'./tmp/chrome/'),
)
})
gulp.task('chrome:zip', () => {
return pipe('./tmp/chrome/**/*', $.zip('chrome.zip'), './dist')
})
gulp.task('chrome:_crx', (cb) => {
$.run('C:\\Progra~1\\Google\\Chrome\\Application\\chrome.exe' +
' --pack-extension=' + path.join(__dirname, './tmp/chrome') +
' --pack-extension-key=' + path.join(__dirname, './dist/chrome.pem')
).exec(cb)
})
gulp.task('chrome:crx', ['chrome:_crx'], () => {
return pipe('./tmp/chrome.crx', './dist')
})
// Opera
gulp.task('opera', ['chrome'], () => {
return pipe('./tmp/chrome/**/*', './tmp/opera')
})
gulp.task('opera:nex', () => {
return pipe('./dist/chrome.crx', $.rename('opera.nex'), './dist')
})
// Firefox
gulp.task('firefox:js', () => {
return buildJs([], {FIREFOX: true})
})
gulp.task('firefox', ['firefox:js'], () => {
return merge(
pipe('./icons/**/*', './tmp/firefox/data/icons'),
pipe(['./tmp/*.css'], './tmp/firefox/data/css'),
pipe(['./src/layim/images/**/*','./src/layim/css/modules/layim/**/*.jpg'], './tmp/firefox/data/images'),
pipe(['./tmp/*.js','./libs/*.js'], './tmp/firefox/data/js'),
pipe('./src/config/firefox/firefox.js', $.babel(), './tmp/firefox/lib'),
pipe('./src/config/firefox/package.json',
$.replace('$VERSION', version),
$.replace('$NAME', name),
$.replace('$DESCRIPTION', description),
$.replace('$HOMEPAGE', homepage),
'./tmp/firefox')
)
})
gulp.task('firefox:xpi', (cb) => {
//linux or mac
//$.run('cd ./tmp/firefox && ../../node_modules/.bin/jpm xpi && mkdir -p ../../dist && mv OscIM.xpi ../../dist/firefox.xpi').exec(cb)
//window
$.run('cd ./tmp/firefox & E:/node/OscIM/node_modules/.bin/jpm xpi & move OscIM.xpi ../../dist/firefox.xpi').exec(cb)
})
// Helpers
function pipe(src, ...transforms) {
return transforms.reduce((stream, transform) => {
const isDest = typeof transform === 'string'
return stream.pipe(isDest ? gulp.dest(transform) : transform)
}, gulp.src(src))
}
function buildJs(overrides, ctx) {
const src = [
'./src/api.js',
'./src/common.js',
'./src/util.storage.js',
].concat(overrides)
return pipe(
src,
$.babel(),
$.concat('common.js'),
$.preprocess({context: ctx}),
'./tmp'
)
}
JavaScript
1
https://gitee.com/junluoyu/OscIM.git
git@gitee.com:junluoyu/OscIM.git
junluoyu
OscIM
project_22213009
master

搜索帮助