我的build
任务从不调用copy:build task
,因为看起来transpile
任务没有返回(我从没在控制台中看到transpile任务的“完成”),所以它永远不会继续执行上一个任务:
require('babel-core/register');
var gulp = require('gulp'),
less = require('gulp-less'),
uglify = require('gulp-uglify'),
babel = require("gulp-babel"),
shell = require('gulp-shell'),
mocha = require('gulp-mocha'),
runSequence = require('run-sequence'),
browserify = require('gulp-browserify'),
rename = require('gulp-rename'),
del = require('del');
require('dotenv').config();
const { env } = process;
gulp.task('build', function (done) {
runSequence('clean', 'transpile', 'copy:build', done);
});
gulp.task('clean', function () {
return del(['./build', './dist']);
});
gulp.task('transpile', function () {
return gulp.src(['./src/**/*.js', '!./src/client/less/*.js'])
.pipe(babel())
.pipe(gulp.dest("build"));
});
gulp.task('copy:build', function () {
return gulp.src(['src/shared/**/*.json']).pipe(gulp.dest('build/shared'));
});
package.json
{
"name": "my-app",
"version": "0.0.1",
"description": "",
"main": "server.js",
"scripts": {
"dist": "gulp dist",
"start": "node dist/server.js",
"postinstall": "yarn run dist",
"test-backend": "gulp build && gulp spec-backend",
"test-frontend": "gulp build && yarn run flow && gulp spec-frontend",
"test-all": "gulp build && spec-all",
"build": "NODE_ENV=production gulp build",
"local": "NODE_ENV=development gulp dist && npm start"
},
"repository": {
"type": "git",
"url": "git+https://github.com/me/my-app.git"
},
"author": "Me",
"license": "",
"bugs": {
"url": "https://github.com/me/my-app/issues"
},
"homepage": "https://github.com/me/my-app#readme",
"dependencies": {
"browserify": "^16.2.3",
"compression": "^1.7.3",
"connect-history-api-fallback": "^1.5.0",
"core-js": "^2.6.1",
"cors": "^2.8.5",
"del": "^3.0.0",
"dotenv": "^6.2.0",
"express": "^4.16.4",
"gulp-cli": "^2.0.1",
"gulp-if": "^2.0.2",
"gulp-less": "^4.0.1",
"gulp-rename": "^1.4.0",
"lodash": "^4.17.11",
"nock": "^10.0.5",
"prop-types": "^15.6.2",
"react": "^16.7.0",
"react-addons-create-fragment": "^15.6.2",
"react-compat": "^0.0.1",
"react-document-title": "^2.0.3",
"react-dom": "^16.7.0",
"react-ga": "^2.5.6",
"react-grid-gallery": "^0.5.3",
"react-redux": "^5.0.1",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-scroll": "^1.7.10",
"redux": "^3.6.0",
"redux-thunk": "^2.3.0",
"superagent": "^4.1.0"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/cli": "^7.1.5",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.1.0",
"@babel/preset-env": "^7.1.6",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"@babel/runtime": "^7.1.5",
"babel-eslint": "^10.0.1",
"babel-preset-flow": "^6.23.0",
"babelify": "^10.0.0",
"chai": "^4.2.0",
"enzyme": "^3.8.0",
"enzyme-adapter-react-16": "^1.7.1",
"eslint": "^5.11.1",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.12.0",
"flow-bin": "^0.89.0",
"flowtypify": "^1.0.1",
"gulp": "^3.9.1",
"gulp-babel": "^8.0.0",
"gulp-browserify": "^0.5.1",
"gulp-bundle-assets": "^2.29.0",
"gulp-mocha": "^6.0.0",
"gulp-shell": "^0.6.5",
"gulp-uglify": "^3.0.1",
"gulp-wait": "^0.0.2",
"jquery": "^3.1.1",
"jsdom": "^13.1.0",
"mocha": "^5.2.0",
"postcss": "^7.0.7",
"postcss-cli": "^6.1.0",
"run-sequence": "^2.2.1",
"sinon": "^7.2.2",
"supertest": "^3.3.0",
"watchify": "^3.11.0"
}
}
这是我在控制台中看到的输出,请注意您看不到transpile任务的“ Finished”,这就是为什么它从不运行“ copy:build”任务的原因:
所以发生的事情是使我回到控制台Starting 'transpile'...
的最后一行,好像已经完成了,但是显然不是,因为它没有显示完成,也没有运行过我的copy:build
任务。
尝试直接运行copy:build任务,效果很好。问题在于可移植脚本甚至从未到达过这里:
答案 0 :(得分:1)
我必须删除退货:
gulp.task('transpile', function () {
gulp.src(['./src/**/*.js', '!./src/client/less/*.js'])
.pipe(babel())
.pipe(gulp.dest("build"));
});