Browse Source

Initial commit

master
Mobius K 3 years ago
commit
9406388aee
  1. 13
      .editorconfig
  2. 8
      .gitignore
  3. 3
      README.md
  4. 89
      gulpfile.js

13
.editorconfig

@ -0,0 +1,13 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

8
.gitignore

@ -0,0 +1,8 @@
# Editor files
.idea
# Build dependencies
node_modules
# Build output
dist

3
README.md

@ -0,0 +1,3 @@
# Bluetooth Class
Builder for hcitool class codes

89
gulpfile.js

@ -0,0 +1,89 @@
const browserSync = require("browser-sync").create();
const cacheBuster = require("gulp-cache-bust");
const clean = require("gulp-clean");
const concat = require("gulp-concat");
const gulp = require("gulp");
const include = require("gulp-include");
const pug = require("gulp-pug");
const sass = require("gulp-sass");
const terser = require("gulp-terser");
// Creating objects for/from NPM modules
const srcDir = "src";
const outDir = "dist";
// Clean the build directory
gulp.task("clean", function () {
return gulp
.src(outDir, {allowEmpty: true})
.pipe(clean());
});
// Copy assets to the build directory
gulp.task("assets", function () {
return gulp
.src(`${srcDir}/assets/**/*`)
.pipe(gulp.dest(outDir))
.pipe(browserSync.stream());
});
// Process all of our SCSS files into the build
gulp.task("css", function () {
return gulp
.src(`${srcDir}/styles/index.scss`)
.pipe(sass({outputStyle: "compressed"}).on("error", sass.logError))
.pipe(concat("index.css"))
.pipe(gulp.dest(outDir))
.pipe(browserSync.stream());
});
// Process all of our HTML files into the build
gulp.task("html", function () {
return gulp
.src(`${srcDir}/routes/**/*.pug`)
.pipe(pug())
.pipe(gulp.dest(outDir))
.pipe(browserSync.stream());
});
// Process all of our JS files into the build
gulp.task("js", function () {
return gulp
.src(`${srcDir}/scripts/index.js`)
.pipe(include())
.pipe(terser())
.pipe(gulp.dest(outDir))
.pipe(browserSync.stream());
});
// Start a BrowserSync server that executes tasks on file changes
gulp.task("sync", function () {
browserSync.init({
server: {
baseDir: `${outDir}/`,
serveStaticOptions: {
extensions: ["html"],
},
},
});
gulp.watch(`${srcDir}/assets/**/*`, gulp.series("assets"));
gulp.watch(`${srcDir}/**/*.scss`, gulp.series("css"));
gulp.watch(`${srcDir}/**/*.js`, gulp.series("js"));
gulp.watch(`${srcDir}/**/*.pug`, gulp.series("html", "css"));
});
// Create a production build
gulp.task("cacheBuster", function () {
return gulp
.src(`${outDir}/index.html`)
.pipe(cacheBuster())
.pipe(gulp.dest(outDir))
});
gulp.task("build", gulp.series("clean", "assets", "html", "js", "css", "cacheBuster"));
// Tasks run on default `gulp` invocation
gulp.task("default", gulp.series("build", "sync"));
Loading…
Cancel
Save