Answer the question
In order to leave comments, you need to log in
How to import one stylus file into several others using gulp?
There is a big bunch of stylus files, they should be compiled into css, but not assembled into one, because of this there is a small problem, I would not want to write import variable.styl in each file. And I would like this import to make a gallp during assembly, i.e. I imported variable.styl into each file.
gulpfile.js code
gulp.task('stylus', function () {
gulp.src(['source/styl_variable/*.styl', 'source/Layout-Desktop/stylus/*.styl'])
.pipe(stylus({
import: 'variable.styl'
}))
.pipe(gulp.dest('build')
});
failed to locate @import file variable.styl
Answer the question
In order to leave comments, you need to log in
Since the option with concat did not work for me. I went the other way. With gulp-insert, I added the contents of one file to another. The code turned out like this -
...//подключаем галп и все такое
var insert = require('gulp-insert');
var fs = require("fs")
gulp.task('stylus', function () {
var variableContent = fs.readFileSync("source/styl_variable/variable.styl", "utf8");
gulp.src('source/Layout-Desktop/stylus/*.styl')
.pipe(insert.transform(function(contents, file) {
return variableContent + '\n' + contents;
}))
.pipe(gulp.dest('build'))
Is there any solution to this problem without resorting to pushing imports in each styl file?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question