Reference article that I followed to upload files to SharePoint Library: Automate publishing of your SharePoint Framework scripts to Office 365 public CDN. I updated write-manifests.json with correct cdnBasePath value and below is the gulpfile code looks like
'use strict';
const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');
const spSync = require('gulp-spsync');
build.task('upload-to-sharepoint', {
execute: (config) => {
return new Promise((resolve, reject) => {
const deployFolder = require('./config/copy-assets.json');
const folderLocation = `./${deployFolder.deployCdnPath}/**/*.js`;
return gulp.src(folderLocation)
.pipe(spSync({
"client_id": paramter.clientId,
"client_secret": paramter.clientSecret,
"site": `https://${paramter.tenant}.sharepoint.com/`,
"libraryPath": paramter.cdnLib,
"publish": true
}))
.on('finish', resolve);
});
}
});
build.initialize(gulp);
When I run gulp task gulp upload-to-sharepoint --ship
I am getting error:
Uploading sample_en-us_6148166309dc16f1da067900ef6b71b1.js Unhandled rejection Error in plugin 'gulp-spsync' Message: Request error
About to exit with code: 0 Process terminated before summary could be written, possible error in async code not continuing! Trying to exit with exit code 1
I can successfully run other gulp task like gulp bundle, gulp serve