Запуск tailwind css запускается
npm run build
Как запускать tailwind в gulp и настраивать его через tailwind.config.js
{
"name": "Template",
"version": "1.0.0",
"description": "Layout template for gulp",
"main": "index.js",
"scripts": {
"build": "postcss ./#src/stylus/tailwind.styl -o ./dist/css/tailwind/tailwind.css",
"prod": "NODE_ENV=production postcss ./#src/stylus/tailwind.styl -o ./dist/css/tailwind/tailwind.css"
},
"author": "Serghei Ponomariov",
"license": "ISC",
"devDependencies": {
"babel-plugin-preval": "^5.0.0",
"browser-sync": "^2.26.7",
"del": "^5.1.0",
"gulp": "^4.0.2",
"gulp-autoprefixer": "^7.0.1",
"gulp-clean-css": "^4.3.0",
"gulp-group-css-media-queries": "^1.2.2",
"gulp-imagemin": "^7.1.0",
"gulp-rename": "^2.0.0",
"gulp-stylus": "^2.7.0",
"gulp-svg-sprite": "^1.5.0",
"gulp-uglify-es": "^2.0.0",
"gulp-webp": "^4.0.1",
"gulp-webp-html": "^1.0.2",
"gulp-webpcss": "^1.1.1",
"poststylus": "^1.0.1",
"webp-converter": "^2.2.3"
},
"dependencies": {
"cssnano": "^4.1.11",
"gulp-file-include": "^2.2.2",
"gulp-postcss": "^9.0.0",
"gulp-pug": "^4.0.1",
"postcss-cli": "^8.3.1",
"postcss-import": "^14.0.1",
"precss": "^4.0.0",
"tailwindcss": "^2.1.1"
}
}
Gulpfile.js
let project_folder = "dist";
let source_folder = "#src";
let path = {
build: {
html: project_folder + "/",
css: project_folder + "/css/",
js: project_folder + "/js/",
img: project_folder + "/img/",
fonts: project_folder + "/fonts/",
},
src: {
html: [source_folder + "/views/*.pug", "!" + source_folder + "/views/_*.pug"],
css: source_folder + "/stylus/*.+(styl|css)",
js: source_folder + "/js/script.js",
img: source_folder + "/img/**/*.+(png|jpg|gif|ico|svg|webp)",
fonts: source_folder + "/fonts/*.ttf",
},
watch: {
html: source_folder + "/**/*.pug",
css: source_folder + "/stylus/**/*.+(styl|css)",
js: source_folder + "/js/*.js",
img: source_folder + "/img/**/*.+(png|jpg|gif|ico|svg|webp) "
},
clean: "./" + project_folder + "/"
}
let {
src,
dest
} = require('gulp'),
gulp = require('gulp'),
browsersync = require("browser-sync").create();
fileinclude = require("gulp-file-include");
del = require("del");
stylus = require("gulp-stylus");
auto_prefixer = require("gulp-autoprefixer");
clean_css = require("gulp-clean-css");
rename_file = require("gulp-rename");
uglify = require("gulp-uglify-es").default;
imagemin = require("gulp-imagemin");
webp = require("gulp-webp");
webphtml = require("gulp-webp-html");
webpcss = require("gulp-webpcss");
pug = require('gulp-pug');
postcss = require('gulp-postcss');
tailwindcss = require("tailwindcss");
cssnano = require("cssnano")
function browserSync(params) {
browsersync.init({
server: {
baseDir: "./" + project_folder + "/"
},
port: 3000,
notify: false
})
}
function html() {
return src(path.src.html)
.pipe(pug({}))
.pipe(fileinclude())
.pipe(webphtml())
.pipe(dest(path.build.html))
.pipe(browsersync.stream())
}
function images() {
return src(path.src.img)
.pipe(
webp({
quality: 70
})
)
.pipe(dest(path.build.img))
.pipe(src(path.src.img))
.pipe(
imagemin({
progressive: true,
svgoPlugins: [{
removeViewBox: false
}],
interlaced: true,
optimizationLevel: 3 // 0 to 7
})
)
.pipe(dest(path.build.img))
.pipe(browsersync.stream())
}
function css() {
return src(path.src.css)
.pipe(
stylus({
// Сжатие css в dist
compress: false,
})
)
.pipe(webpcss())
.pipe(dest(path.build.css))
.pipe(clean_css())
.pipe(
rename_file({
extname: ".min.css"
})
)
.pipe(dest(path.build.css))
.pipe(browsersync.stream())
}
function js() {
return src(path.src.js)
.pipe(fileinclude())
.pipe(dest(path.build.js))
.pipe(
uglify()
)
.pipe(
rename_file({
extname: ".min.js"
})
)
.pipe(dest(path.build.js))
.pipe(browsersync.stream())
}
function clean(params) {
return del(path.clean);
}
gulp.task('svgSprite', function () {
return gulp.src([source_folder + '/icons/*.svg'])
.pipe(svgSprite({
mode: {
stack: {
sprite: "../icons/icon.svg", //Название файла для спрайтов
example: true
},
}
}))
.pipe(dest(path.build.img))
})
function watchFiles(params) {
gulp.watch([path.watch.html], html);
gulp.watch([path.watch.css], css);
gulp.watch([path.watch.js], js);
gulp.watch([path.watch.img], images);
}
let build = gulp.series(clean, gulp.parallel(html, css, js, images));
let watch = gulp.parallel(build, watchFiles, browserSync);
exports.html = html;
exports.js = js;
exports.css = css;
exports.images = images;
exports.build = build;
exports.watch = watch;
exports.default = watch;