質問するログイン新規登録

回答編集履歴

2

修正

2019/10/29 00:56

投稿

s8_chu
s8_chu

スコア14731

answer CHANGED
@@ -52,4 +52,22 @@
52
52
  };
53
53
 
54
54
  exports.build = series(compileSass, reload);
55
+ ```
56
+
57
+ ---
58
+
59
+ **追記**
60
+
61
+ ```JavaScript
62
+ exports.default = () => {
63
+ browserSync.init({
64
+ browser: 'Google Chrome',
65
+ server: {
66
+ baseDir: './',
67
+ index: './index.html',
68
+ },
69
+ });
70
+ watch(path['sass']).on("change", (path) => series(compileSass.bind(this, path), reload)());
71
+ watch(Object.values(path).filter(value => value !== path["sass"]), reload);
72
+ };
55
73
  ```

1

修正

2019/10/29 00:56

投稿

s8_chu
s8_chu

スコア14731

answer CHANGED
@@ -17,9 +17,6 @@
17
17
  } = require("gulp");
18
18
  const sass = require("gulp-sass");
19
19
  const browserSync = require("browser-sync");
20
- const log = require("fancy-log");
21
- const chalk = require("chalk");
22
- const prettyTime = require("pretty-hrtime");
23
20
  const path = {
24
21
  html: "./*.html",
25
22
  js: "js/*.js",
@@ -27,21 +24,12 @@
27
24
  };
28
25
 
29
26
  function compileSass(filePath) {
30
- const time = process.hrtime();
31
- log(`Starting '${chalk.cyan("compileSass")}' ...`);
32
-
33
27
  return src(path["sass"])
34
28
  .pipe(sass({outputStyle: "expanded"}))
35
- .on("end", () => {
29
+ .on("end", _ => {
36
- if (typeof filePath === "function") {
30
+ if (typeof filePath === "string") console.log(`Compiled '${filePath}'`);
37
- log(`Compiled '${chalk.magenta(filePath)}'`);
38
- }
39
31
  })
40
32
  .pipe(dest("css"))
41
- .on("end", () => {
42
- const duration = prettyTime(process.hrtime(time));
43
- log(`Finished '${chalk.cyan("compileSass")}', after ${chalk.magenta(duration)}`);
44
- });
45
33
  }
46
34
 
47
35
  function reload(done) {