gpt4 book ai didi

css - 使用gulp + foundation(sass版)报错

转载 作者:行者123 更新时间:2023-11-28 04:15:21 24 4
gpt4 key购买 nike

我想使用 gulp + Foundation 6 + browserify。在 cli 中运行 gulp 时,我在终端中出现此错误

write ./scss.css/foundation.css
path.js:7
throw new TypeError('Path must be a string. Received ' + inspect(path));
^

TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.join (path.js:1211:7)
at exports.replaceLocation (/Applications/MAMP/htdocs/Jober/node_modules/gulp-ruby-sass/lib/utils.js:32:14)
at /Applications/MAMP/htdocs/Jober/node_modules/gulp-ruby-sass/index.js:179:13
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:416:3)

我的 gulpfile.js 是:

var gulp        = require ('gulp'),
logger = require ('gulp-util'),
concat = require ('gulp-concat'),
minifyCSS = require ('gulp-minify-css'),
compileSass = require ('gulp-ruby-sass');

var scss_sources,
input_address,
output_address;

// Input and Output Address
input_address = 'asstes/src/';
output_address = 'asstes/dist/';

// Style Sources
scss_sources = [
'node_modules/foundation-sites/scss',
input_address + 'style/style.scss'];

gulp.task('styles', function(){
return compileSass(scss_sources, { style: 'expanded' })
.pipe(autoprefixer({
browsers: ['last 2 versions', 'ie >= 9', 'and_chr >= 2.3'],
cascade: false
}))
.pipe(minifyCSS())
.on('error', logger.log)
.pipe(gulp.dest(output_address + 'style'));
});

gulp.task('watch', function(){
gulp.watch(input_address + 'style/pages/*.scss', ['styles']),
});

gulp.task('default', ['styles' , 'watch']);

我的 style.scss 是:

//Modules
@import 'foundation';

//Pages
@import 'pages/index';

我的文件夹结构是:

PROJECT FOLDER
|
|_assets
| |_dist
| | |_img
| | |_js
| | |_style
| |
| |_src
| |_img
| |_js
| |_style
|
|_node_modules
| |_foundation-site
|
|_gulpfile.js

我在 gulp-ruby-sass 之前使用 gulp-compass 但是,有一个流行的错误:Individual stylesheets must be in the sass directory, therefore change plugin to gulp-ruby-sass.

我该如何解决?

最佳答案

可能是字符串连接在 scss_sources 中无法正常工作。

尝试将 scss_sources 更改为:

scss_sources = [
'node_modules/foundation-sites/scss',
'asstes/src/style/style.scss'
];

看看它是否有效,如果有效,那就是连接。

关于css - 使用gulp + foundation(sass版)报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42508240/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com