Change output directory to public
This commit is contained in:
parent
25cb59ac44
commit
699f93fdbc
2 changed files with 17 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -302,3 +302,4 @@ $RECYCLE.BIN/
|
||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/node,now,visualstudiocode,webstorm+all,windows,macos,linux
|
# End of https://www.toptal.com/developers/gitignore/api/node,now,visualstudiocode,webstorm+all,windows,macos,linux
|
||||||
|
|
||||||
|
/public
|
||||||
|
|
26
gulpfile.js
26
gulpfile.js
|
@ -1,41 +1,47 @@
|
||||||
|
const { join, resolve } = require("path");
|
||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
const postcss = require("gulp-postcss");
|
const postcss = require("gulp-postcss");
|
||||||
const sass = require("gulp-sass")(require("sass"));
|
const sass = require("gulp-sass")(require("sass"));
|
||||||
const sourcemaps = require("gulp-sourcemaps");
|
const sourcemaps = require("gulp-sourcemaps");
|
||||||
const terser = require("gulp-terser");
|
const terser = require("gulp-terser");
|
||||||
|
|
||||||
|
const SOURCE_DIR = resolve(__dirname, "src");
|
||||||
|
const OUTPUT_DIR = resolve(__dirname, "public");
|
||||||
|
|
||||||
function html() {
|
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() {
|
function css() {
|
||||||
return gulp
|
return gulp
|
||||||
.src("./src/scss/*.scss")
|
.src(join(SOURCE_DIR, "scss", "*.scss"))
|
||||||
.pipe(sourcemaps.init())
|
.pipe(sourcemaps.init())
|
||||||
.pipe(sass.sync().on("error", sass.logError))
|
.pipe(sass.sync().on("error", sass.logError))
|
||||||
.pipe(postcss([require("autoprefixer"), require("postcss-csso")]))
|
.pipe(postcss([require("autoprefixer"), require("postcss-csso")]))
|
||||||
.pipe(sourcemaps.write("."))
|
.pipe(sourcemaps.write("."))
|
||||||
.pipe(gulp.dest("./dist/"));
|
.pipe(gulp.dest(OUTPUT_DIR));
|
||||||
}
|
}
|
||||||
|
|
||||||
function js() {
|
function js() {
|
||||||
return gulp
|
return gulp
|
||||||
.src("./src/main.js")
|
.src(join(SOURCE_DIR, "main.js"))
|
||||||
.pipe(sourcemaps.init())
|
.pipe(sourcemaps.init())
|
||||||
.pipe(terser({ ecma: 5 }))
|
.pipe(terser({ ecma: 5 }))
|
||||||
.pipe(sourcemaps.write("."))
|
.pipe(sourcemaps.write("."))
|
||||||
.pipe(gulp.dest("./dist/"));
|
.pipe(gulp.dest(OUTPUT_DIR));
|
||||||
}
|
}
|
||||||
|
|
||||||
function static() {
|
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.default = gulp.parallel(html, css, js, static);
|
||||||
|
|
||||||
exports.watch = () => {
|
exports.watch = () => {
|
||||||
gulp.watch("./src/index.html", html);
|
gulp.watch(join(SOURCE_DIR, "index.html"), html);
|
||||||
gulp.watch("./src/scss/*.scss", css);
|
gulp.watch(join(SOURCE_DIR, "scss", "*.scss"), css);
|
||||||
gulp.watch("./src/main.js", js);
|
gulp.watch(join(SOURCE_DIR, "main.js"), js);
|
||||||
gulp.watch("./src/static/*", static);
|
gulp.watch(join(SOURCE_DIR, "static", "**", "*"), static);
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue