升级gulp
This commit is contained in:
parent
c37ac29995
commit
8680ed4aa1
166
gulpfile.js
166
gulpfile.js
|
@ -1,66 +1,100 @@
|
||||||
var gulp = require('gulp');
|
{
|
||||||
var $ = require('gulp-load-plugins')();
|
"name": "renren-fast-vue",
|
||||||
var path = require('path');
|
"version": "1.2.2",
|
||||||
var del = require('del');
|
"description": "renren-fast-vue基于vue、element-ui构建开发,实现renren-fast后台管理前端功能,提供一套更优的前端解决方案。",
|
||||||
|
"author": "daxiong.yang <daxiong.yang@qq.com>",
|
||||||
var distPath = path.resolve('./dist');
|
"private": true,
|
||||||
var version = ''; // 版本号
|
"scripts": {
|
||||||
var versionPath = ''; // 版本号路径
|
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
|
||||||
var env = ''; // 运行环境
|
"start": "npm run dev",
|
||||||
|
"unit": "jest --config test/unit/jest.conf.js --coverage",
|
||||||
// 创建版本号(年月日时分)
|
"e2e": "node test/e2e/runner.js",
|
||||||
(function () {
|
"test": "npm run unit && npm run e2e",
|
||||||
var d = new Date();
|
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs",
|
||||||
var yy = d.getFullYear().toString().slice(2);
|
"build": "gulp"
|
||||||
var MM = d.getMonth() + 1 >= 10 ? (d.getMonth() + 1) : '0' + (d.getMonth() + 1);
|
},
|
||||||
var DD = d.getDate() >= 10 ? d.getDate() : '0' + d.getDate();
|
"dependencies": {
|
||||||
var h = d.getHours() >= 10 ? d.getHours() : '0' + d.getHours();
|
"axios": "0.17.1",
|
||||||
var mm = d.getMinutes() >= 10 ? d.getMinutes() : '0' + d.getMinutes();
|
"babel-plugin-component": "0.10.1",
|
||||||
version = yy + MM + DD + h + mm;
|
"babel-polyfill": "6.26.0",
|
||||||
versionPath = distPath + '/' + version;
|
"element-ui": "2.8.2",
|
||||||
})();
|
"gulp": "4.0.2",
|
||||||
|
"gulp-concat": "2.6.1",
|
||||||
// 编译
|
"gulp-load-plugins": "2.0.5",
|
||||||
gulp.task('build', $.shell.task([ 'node build/build.js' ]));
|
"gulp-replace": "1.0.0",
|
||||||
|
"gulp-shell": "0.8.0",
|
||||||
// 创建版本号目录
|
"lodash": "4.17.5",
|
||||||
gulp.task('create:versionCatalog', ['build'], function () {
|
"node-sass": "4.13.1",
|
||||||
return gulp.src(`${distPath}/static/**/*`)
|
"npm": "^6.9.0",
|
||||||
.pipe(gulp.dest(`${versionPath}/static/`))
|
"sass-loader": "6.0.6",
|
||||||
});
|
"svg-sprite-loader": "3.7.3",
|
||||||
|
"vue": "2.5.16",
|
||||||
// 替换${versionPath}/static/js/manifest.js window.SITE_CONFIG.cdnUrl占位变量
|
"vue-cookie": "1.1.4",
|
||||||
gulp.task('replace:cdnUrl', ['create:versionCatalog'], function () {
|
"vue-router": "3.0.1",
|
||||||
return gulp.src(`${versionPath}/static/js/manifest.js`)
|
"vuex": "3.0.1"
|
||||||
.pipe($.replace(new RegExp(`"${require('./config').build.assetsPublicPath}"`, 'g'), 'window.SITE_CONFIG.cdnUrl + "/"'))
|
},
|
||||||
.pipe(gulp.dest(`${versionPath}/static/js/`))
|
"devDependencies": {
|
||||||
});
|
"autoprefixer": "7.1.2",
|
||||||
|
"babel-core": "6.22.1",
|
||||||
// 替换${versionPath}/static/config/index-${env}.js window.SITE_CONFIG['version']配置变量
|
"babel-eslint": "7.1.1",
|
||||||
gulp.task('replace:version', ['create:versionCatalog'], function () {
|
"babel-jest": "21.0.2",
|
||||||
return gulp.src(`${versionPath}/static/config/index-${env}.js`)
|
"babel-loader": "7.1.1",
|
||||||
.pipe($.replace(/window.SITE_CONFIG\['version'\] = '.*'/g, `window.SITE_CONFIG['version'] = '${version}'`))
|
"babel-plugin-dynamic-import-node": "1.2.0",
|
||||||
.pipe(gulp.dest(`${versionPath}/static/config/`))
|
"babel-plugin-transform-es2015-modules-commonjs": "6.26.0",
|
||||||
});
|
"babel-plugin-transform-runtime": "6.22.0",
|
||||||
|
"babel-preset-env": "1.3.2",
|
||||||
// 合并${versionPath}/static/config/[index-${env}, init].js 至 ${distPath}/config/index.js
|
"babel-preset-stage-2": "6.22.0",
|
||||||
gulp.task('concat:config', ['replace:version'], function () {
|
"babel-register": "6.22.0",
|
||||||
return gulp.src([`${versionPath}/static/config/index-${env}.js`, `${versionPath}/static/config/init.js`])
|
"chalk": "2.3.0",
|
||||||
.pipe($.concat('index.js'))
|
"chromedriver": "2.27.2",
|
||||||
.pipe(gulp.dest(`${distPath}/config/`))
|
"copy-webpack-plugin": "4.0.1",
|
||||||
});
|
"cross-spawn": "5.0.1",
|
||||||
|
"css-loader": "0.28.0",
|
||||||
// 清空
|
"eslint": "3.19.0",
|
||||||
gulp.task('clean', function () {
|
"eslint-config-standard": "10.2.1",
|
||||||
return del([versionPath])
|
"eslint-friendly-formatter": "3.0.0",
|
||||||
});
|
"eslint-loader": "1.7.1",
|
||||||
|
"eslint-plugin-html": "3.0.0",
|
||||||
gulp.task('default', ['clean'], function () {
|
"eslint-plugin-import": "2.7.0",
|
||||||
// 获取环境配置
|
"eslint-plugin-node": "5.2.0",
|
||||||
env = process.env.npm_config_qa ? 'qa' : process.env.npm_config_uat ? 'uat' : 'prod'
|
"eslint-plugin-promise": "3.5.0",
|
||||||
// 开始打包编译
|
"eslint-plugin-standard": "3.0.1",
|
||||||
gulp.start(['build', 'create:versionCatalog', 'replace:cdnUrl', 'replace:version', 'concat:config'], function () {
|
"eventsource-polyfill": "0.9.6",
|
||||||
// 清除, 编译 / 处理项目中产生的文件
|
"extract-text-webpack-plugin": "3.0.0",
|
||||||
del([`${distPath}/static`, `${versionPath}/static/config`])
|
"file-loader": "1.1.4",
|
||||||
})
|
"friendly-errors-webpack-plugin": "1.6.1",
|
||||||
});
|
"html-webpack-plugin": "2.30.1",
|
||||||
|
"jest": "21.2.0",
|
||||||
|
"jest-serializer-vue": "0.3.0",
|
||||||
|
"nightwatch": "0.9.12",
|
||||||
|
"node-notifier": "5.1.2",
|
||||||
|
"optimize-css-assets-webpack-plugin": "3.2.0",
|
||||||
|
"ora": "1.2.0",
|
||||||
|
"portfinder": "1.0.13",
|
||||||
|
"postcss-import": "11.0.0",
|
||||||
|
"postcss-loader": "2.0.8",
|
||||||
|
"rimraf": "2.6.0",
|
||||||
|
"selenium-server": "3.0.1",
|
||||||
|
"semver": "5.3.0",
|
||||||
|
"shelljs": "0.7.6",
|
||||||
|
"uglifyjs-webpack-plugin": "1.1.1",
|
||||||
|
"url-loader": "0.5.8",
|
||||||
|
"vue-jest": "1.0.2",
|
||||||
|
"vue-loader": "13.3.0",
|
||||||
|
"vue-style-loader": "3.0.1",
|
||||||
|
"vue-template-compiler": "2.5.16",
|
||||||
|
"webpack": "3.6.0",
|
||||||
|
"webpack-bundle-analyzer": "2.9.0",
|
||||||
|
"webpack-dev-server": "2.9.1",
|
||||||
|
"webpack-merge": "4.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8.11.1",
|
||||||
|
"npm": ">= 5.6.0"
|
||||||
|
},
|
||||||
|
"browserslist": [
|
||||||
|
"> 1%",
|
||||||
|
"last 2 versions",
|
||||||
|
"not ie <= 8"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue