gulp 針對某目錄下的所有檔案處理後,如果要能根據目錄結構輸出到另一個目錄,記得要指定 {‘base’: 來源根目錄}:
https://github.com/gulpjs/gulp/blob/master/docs/API.md#optionsbase
// without the 'base' set
gulp.src('app/**/*.scss') // file: 'app/css/somefile.scss'
.pipe(gulp.dest('build')); //-> file base: 'app/css'
// relative path: 'somefile.scss'
// write path: 'build/somefile.scss'
// with the 'base' set
var glob = 'app/**/*.scss';
gulp.src(glob, { base: 'app' }) // file: 'app/css/somefile.scss'
.pipe(gulp.dest('build')); //-> file base: 'app'
// relative path: 'css/somefile.scss'
// write path: 'build/css/somefile.scss'
星期二, 9月 30, 2014
星期四, 9月 11, 2014
[Gulp 問題] “Possibly unhandled Error: path should be string...” when gulp build
不知怎搞的,才剛 build 沒事,緊接著改了無關緊要的 code,就出現了如下的錯誤訊息:
indiana@indiana-dt:.../program/web/my-project$ gulp build
[10:52:54] Using gulpfile ~/program/web/my-project/gulpfile.js
[10:52:54] Starting 'styles'...
[10:52:54] Starting 'scripts'...
[10:52:54] Starting 'images'...
[10:52:54] Starting 'fonts'...
[10:52:55] Starting 'extras'...
[10:52:55] Starting 'move'...
/home/indiana/program/web/my-project/app/scripts/facebook.js
line 46 col 9 'alert' is not defined.
line 63 col 50 'params' is defined but never used.
line 82 col 52 'widget' is defined but never used.
line 82 col 46 'href' is defined but never used.
✖ 4 problems
Possibly unhandled Error: path should be string
at File.Object.defineProperty.set (/home/indiana/program/web/my-project/node_modules/gulp/node_modules/vinyl-fs/node_modules/vinyl/index.js:166:41)
at Function.assign (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/lodash-node/modern/objects/assign.js:63:21)
at /home/indiana/program/web/my-project/node_modules/gulp-cache/lib/TaskProxy.js:20:19
at tryCatch1 (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/util.js:64:19)
at Promise$_callHandler [as _callHandler] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:708:13)
at Promise$_settlePromiseFromHandler [as _settlePromiseFromHandler] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:724:18)
at Promise$_settlePromiseAt [as _settlePromiseAt] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:896:14)
at Promise$_fulfillPromises [as _fulfillPromises] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:1041:14)
at Async$_consumeFunctionBuffer [as _consumeFunctionBuffer] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/async.js:64:12)
at Async$consumeFunctionBuffer (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/async.js:37:14)
Possibly unhandled Error: path should be string
at File.Object.defineProperty.set (/home/indiana/program/web/my-project/node_modules/gulp/node_modules/vinyl-fs/node_modules/vinyl/index.js:166:41)
at Function.assign (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/lodash-node/modern/objects/assign.js:63:21)
at /home/indiana/program/web/my-project/node_modules/gulp-cache/lib/TaskProxy.js:20:19
at tryCatch1 (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/util.js:64:19)
at Promise$_callHandler [as _callHandler] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:708:13)
at Promise$_settlePromiseFromHandler [as _settlePromiseFromHandler] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:724:18)
at Promise$_settlePromiseAt [as _settlePromiseAt] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:896:14)
at Promise$_fulfillPromises [as _fulfillPromises] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:1041:14)
at Async$_consumeFunctionBuffer [as _consumeFunctionBuffer] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/async.js:64:12)
at Async$consumeFunctionBuffer (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/async.js:37:14)
[10:52:55] gulp-size: total 19.5 kB
[10:52:55] Finished 'scripts' after 864 ms
[10:52:55] Finished 'move' after 234 ms
[10:52:55] gulp-size: total 699.12 kB
[10:52:55] Finished 'fonts' after 421 ms
[10:52:55] Finished 'extras' after 258 ms
npm WARN package.json wifi@0.0.0 No description
npm WARN package.json wifi@0.0.0 No repository field.
npm WARN package.json wifi@0.0.0 No README data
[10:52:56] gulp-size: total 130.39 kB
[10:52:56] Finished 'styles' after 2.24 s
[10:52:56] Starting 'html'...
[10:53:15] gulp-size: total 2.08 MB
[10:53:15] Finished 'html' after 19 s
indiana@indiana-dt:.../program/web/my-project$
參考文件: https://github.com/jgable/gulp-cache/issues/24
訂閱:
文章 (Atom)