Answer the question
In order to leave comments, you need to log in
How to compile custom css file for each page in Gulp?
Good day to all!
Can you please tell me how to configure gulp correctly?
It is necessary that, for example, for:
- the main page has a file - style.min.css
- the store page - style-shop.min.css
For the main page, import pulls too many style files that are not needed in the store ...
gulpfile.js looks like this
let path = {
build: {
css: project_folder + "/css/",
},
src: {
css: source_folder + "/scss/style.scss",
},
watch: {
css: source_folder + "/scss/**/*.scss",
},
clean: "./" + project_folder + "/"
}
function css() {
return src(path.src.css)
.pipe (
scss({
outputStyle: "expanded"
})
)
.pipe (
group_media()
)
.pipe(
autoprefixer({
overrideBrowserslist: ["last 5 version"],
cascade: true
})
)
.pipe(webpcss())
.pipe(dest(path.build.css))
.pipe(clean_css())
.pipe(
rename({
extname: ".min.css"
})
)
.pipe(dest(path.build.css))
.pipe(browsersync.stream())
}
Answer the question
In order to leave comments, you need to log in
Pass not a specific file to SRC, but a glob template pointing to several files at once.
let path = {
..
src: {
css: source_folder + "/scss/*.scss",
},
..
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question