From 699f93fdbc57f6f24957351300006464b991192d Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Fri, 27 Aug 2021 15:13:50 +0200 Subject: [PATCH] Change output directory to public --- .gitignore | 1 + gulpfile.js | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 561667b..a9c2f3c 100644 --- a/.gitignore +++ b/.gitignore @@ -302,3 +302,4 @@ $RECYCLE.BIN/ # End of https://www.toptal.com/developers/gitignore/api/node,now,visualstudiocode,webstorm+all,windows,macos,linux +/public diff --git a/gulpfile.js b/gulpfile.js index 61e4abd..4092ff5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,41 +1,47 @@ +const { join, resolve } = require("path"); const gulp = require("gulp"); const postcss = require("gulp-postcss"); const sass = require("gulp-sass")(require("sass")); const sourcemaps = require("gulp-sourcemaps"); const terser = require("gulp-terser"); +const SOURCE_DIR = resolve(__dirname, "src"); +const OUTPUT_DIR = resolve(__dirname, "public"); + function html() { - return gulp.src("./src/index.html").pipe(gulp.dest("./dist/")); + return gulp.src(join(SOURCE_DIR, "index.html")).pipe(gulp.dest(OUTPUT_DIR)); } function css() { return gulp - .src("./src/scss/*.scss") + .src(join(SOURCE_DIR, "scss", "*.scss")) .pipe(sourcemaps.init()) .pipe(sass.sync().on("error", sass.logError)) .pipe(postcss([require("autoprefixer"), require("postcss-csso")])) .pipe(sourcemaps.write(".")) - .pipe(gulp.dest("./dist/")); + .pipe(gulp.dest(OUTPUT_DIR)); } function js() { return gulp - .src("./src/main.js") + .src(join(SOURCE_DIR, "main.js")) .pipe(sourcemaps.init()) .pipe(terser({ ecma: 5 })) .pipe(sourcemaps.write(".")) - .pipe(gulp.dest("./dist/")); + .pipe(gulp.dest(OUTPUT_DIR)); } function static() { - return gulp.src("./src/static/**/*").pipe(gulp.dest("./dist/")); + return gulp + .src(join(SOURCE_DIR, "static", "**", "*")) + .pipe(gulp.dest(OUTPUT_DIR)); } exports.default = gulp.parallel(html, css, js, static); exports.watch = () => { - gulp.watch("./src/index.html", html); - gulp.watch("./src/scss/*.scss", css); - gulp.watch("./src/main.js", js); - gulp.watch("./src/static/*", static); + gulp.watch(join(SOURCE_DIR, "index.html"), html); + gulp.watch(join(SOURCE_DIR, "scss", "*.scss"), css); + gulp.watch(join(SOURCE_DIR, "main.js"), js); + gulp.watch(join(SOURCE_DIR, "static", "**", "*"), static); };