| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,5 @@ | |||
| 1 | + const path = require('path'); | ||
| 2 | + | ||
| 1 | 3 | // To run browser-sync with this config: | |
| 2 | 4 | // | |
| 3 | 5 | // - npm install -g browser-sync | |
@@ -53,7 +55,7 @@ module.exports = { | |||
| 53 | 55 | scrollThrottle: 0, | |
| 54 | 56 | reloadDelay: 0, | |
| 55 | 57 | reloadDebounce: 100, | |
| 56 | - plugins: [], | ||
| 58 | + plugins: [path.resolve(__dirname, '..', 'node_modules', 'bs-fullscreen-message')], | ||
| 57 | 59 | injectChanges: true, | |
| 58 | 60 | startPath: null, | |
| 59 | 61 | minify: false, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | const path = require('path'); | |
| 4 | 4 | ||
| 5 | 5 | const gulp = require('gulp'); | |
| 6 | + const gutil = require('gulp-util'); | ||
| 6 | 7 | const sourcemaps = require('gulp-sourcemaps'); | |
| 7 | 8 | ||
| 8 | 9 | const sass = require('gulp-sass'); | |
@@ -14,36 +15,74 @@ const filter = require('gulp-filter'); | |||
| 14 | 15 | ||
| 15 | 16 | const browserSync = require('browser-sync').create(); | |
| 16 | 17 | ||
| 18 | + const webpack = require('webpack'); | ||
| 19 | + const webpackBundler = webpack(require('../webpack.config.js')()); | ||
| 20 | + | ||
| 17 | 21 | const STATIC = path.resolve(__dirname, '..', 'static'); | |
| 18 | 22 | const SASS_SRC = path.resolve(STATIC, 'src', 'stylesheets'); | |
| 19 | 23 | const SASS_TARGET = path.resolve(STATIC, 'target', 'stylesheets'); | |
| 20 | 24 | ||
| 21 | 25 | const { sassSettings, browserslist, remifications } = require('../dev/css-settings'); | |
| 22 | 26 | const bsConfig = require('./bs-config'); | |
| 23 | 27 | ||
| 24 | - gulp.task('watch', (done) => { | ||
| 25 | - browserSync.init(bsConfig); | ||
| 28 | + let INITIAL_BUNDLE = true; | ||
| 26 | 29 | ||
| 30 | + gulp.task('watch', (done) => { | ||
| 27 | 31 | sassGrapher.init(SASS_SRC, { loadPaths: SASS_SRC }); | |
| 28 | 32 | ||
| 29 | - gulp.watch([ | ||
| 30 | - `${SASS_SRC}/**/*.scss`, | ||
| 31 | - ], (event) => { | ||
| 32 | - gulp.src(event.path, { base: SASS_SRC }) | ||
| 33 | - .pipe(sassGrapher.ancestors()) | ||
| 34 | - .pipe(filter(['**', '!**/ie9*', '!**/old-ie.*', '!**/webfonts-*'])) | ||
| 35 | - .pipe(sourcemaps.init({ loadMaps: true })) | ||
| 36 | - .pipe(sass(Object.assign({ | ||
| 37 | - includePath: SASS_SRC, | ||
| 38 | - }, sassSettings))) | ||
| 39 | - .pipe(postcss([ | ||
| 40 | - autoprefixer(browserslist), | ||
| 41 | - pxtorem(remifications), | ||
| 42 | - ])) | ||
| 43 | - .pipe(sourcemaps.write('.')) | ||
| 44 | - .pipe(gulp.dest(SASS_TARGET)) | ||
| 45 | - .pipe(browserSync.stream({ match: '**/*.css' })); | ||
| 46 | - }); | ||
| 33 | + gutil.log('Creating initial JS bundles...', gutil.colors.cyan('one sec')); | ||
| 34 | + | ||
| 35 | + webpackBundler.watch({ | ||
| 36 | + ignored: /node_modules/, | ||
| 37 | + }, (err, stats) => { | ||
| 38 | + if (err) { throw new gutil.PluginError('webpack', err); } | ||
| 39 | + | ||
| 40 | + if (INITIAL_BUNDLE) { | ||
| 41 | + INITIAL_BUNDLE = false; | ||
| 47 | 42 | ||
| 48 | - done(); | ||
| 43 | + browserSync.init(bsConfig); | ||
| 44 | + | ||
| 45 | + gulp.watch([ | ||
| 46 | + `${SASS_SRC}/**/*.scss`, | ||
| 47 | + ], (event) => { | ||
| 48 | + gulp.src(event.path, { base: SASS_SRC }) | ||
| 49 | + .pipe(sassGrapher.ancestors()) | ||
| 50 | + .pipe(filter(['**', '!**/ie9*', '!**/old-ie.*', '!**/webfonts-*'])) | ||
| 51 | + .pipe(sourcemaps.init({ loadMaps: true })) | ||
| 52 | + .pipe(sass(Object.assign({ | ||
| 53 | + includePath: SASS_SRC, | ||
| 54 | + }, sassSettings)).on('error', function sassError(sassErr) { | ||
| 55 | + gutil.log(sassErr.message); | ||
| 56 | + browserSync.sockets.emit('fullscreen:message', { | ||
| 57 | + title: 'Sass Error:', | ||
| 58 | + body: sassErr.message, | ||
| 59 | + timeout: 100000, | ||
| 60 | + }); | ||
| 61 | + this.emit('end'); | ||
| 62 | + })) | ||
| 63 | + .pipe(postcss([ | ||
| 64 | + autoprefixer(browserslist), | ||
| 65 | + pxtorem(remifications), | ||
| 66 | + ])) | ||
| 67 | + .pipe(sourcemaps.write('.')) | ||
| 68 | + .pipe(gulp.dest(SASS_TARGET)) | ||
| 69 | + .pipe(browserSync.stream({ match: '**/*.css' })) | ||
| 70 | + | ||
| 71 | + // all working except you can't clear the fullscreen error message in sass | ||
| 72 | + | ||
| 73 | + .on('end', () => browserSync.sockets.emit('fullscreen:message:clear')); | ||
| 74 | + }); | ||
| 75 | + return done(); | ||
| 76 | + } | ||
| 77 | + if (stats.hasErrors() || stats.hasWarnings()) { | ||
| 78 | + gutil.log(stats.toString('errors-only')); | ||
| 79 | + | ||
| 80 | + return browserSync.sockets.emit('fullscreen:message', { | ||
| 81 | + title: 'Webpack Error:', | ||
| 82 | + body: stats.toString('errors-only'), | ||
| 83 | + timeout: 100000, | ||
| 84 | + }); | ||
| 85 | + } | ||
| 86 | + return browserSync.reload(); | ||
| 87 | + }); | ||
| 49 | 88 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,6 +31,7 @@ | |||
| 31 | 31 | "babel-preset-env": "^1.1.4", | |
| 32 | 32 | "babel-preset-latest": "^6.16.0", | |
| 33 | 33 | "browser-sync": "^2.8.2", | |
| 34 | + "bs-fullscreen-message": "^1.1.0", | ||
| 34 | 35 | "btoa": "1.1.2", | |
| 35 | 36 | "chalk": "^1.1.3", | |
| 36 | 37 | "check-dependencies": "^0.11.0", | |
@@ -57,6 +58,7 @@ | |||
| 57 | 58 | "gulp-sass": "^3.1.0", | |
| 58 | 59 | "gulp-sass-grapher": "^0.1.4", | |
| 59 | 60 | "gulp-sourcemaps": "^1.5.2", | |
| 61 | + "gulp-util": "^3.0.8", | ||
| 60 | 62 | "gzip-size": "^3.0.0", | |
| 61 | 63 | "hasha": "^2.2.0", | |
| 62 | 64 | "jasmine-core": "^2.3.2", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1174,6 +1174,10 @@ browserslist@^1.4.0, browserslist@~1.4.0: | |||
| 1174 | 1174 | dependencies: | |
| 1175 | 1175 | caniuse-db "^1.0.30000539" | |
| 1176 | 1176 | ||
| 1177 | + bs-fullscreen-message@^1.1.0: | ||
| 1178 | + version "1.1.0" | ||
| 1179 | + resolved "https://registry.yarnpkg.com/bs-fullscreen-message/-/bs-fullscreen-message-1.1.0.tgz#9a479a6b9fdd46e1a67b4f37568b3d43d9f2777b" | ||
| 1180 | + | ||
| 1177 | 1181 | bs-recipes@1.2.3: | |
| 1178 | 1182 | version "1.2.3" | |
| 1179 | 1183 | resolved "https://registry.yarnpkg.com/bs-recipes/-/bs-recipes-1.2.3.tgz#0e4d17bb1cff92ef6c36608b8487d9a07571ac54" | |
@@ -1875,13 +1879,17 @@ date-now@^0.1.4: | |||
| 1875 | 1879 | version "0.1.4" | |
| 1876 | 1880 | resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" | |
| 1877 | 1881 | ||
| 1878 | - dateformat@^1.0.11, dateformat@^1.0.6: | ||
| 1882 | + dateformat@^1.0.6: | ||
| 1879 | 1883 | version "1.0.12" | |
| 1880 | 1884 | resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" | |
| 1881 | 1885 | dependencies: | |
| 1882 | 1886 | get-stdin "^4.0.1" | |
| 1883 | 1887 | meow "^3.3.0" | |
| 1884 | 1888 | ||
| 1889 | + dateformat@^2.0.0: | ||
| 1890 | + version "2.0.0" | ||
| 1891 | + resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-2.0.0.tgz#2743e3abb5c3fc2462e527dca445e04e9f4dee17" | ||
| 1892 | + | ||
| 1885 | 1893 | debug-fabulous@0.0.X: | |
| 1886 | 1894 | version "0.0.4" | |
| 1887 | 1895 | resolved "https://registry.yarnpkg.com/debug-fabulous/-/debug-fabulous-0.0.4.tgz#fa071c5d87484685424807421ca4b16b0b1a0763" | |
@@ -3200,15 +3208,15 @@ gulp-sourcemaps@^1.5.2: | |||
| 3200 | 3208 | through2 "2.X" | |
| 3201 | 3209 | vinyl "1.X" | |
| 3202 | 3210 | ||
| 3203 | - gulp-util@^3.0, gulp-util@^3.0.0, gulp-util@^3.0.4, gulp-util@^3.0.6, gulp-util@^3.0.7: | ||
| 3204 | - version "3.0.7" | ||
| 3205 | - resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.7.tgz#78925c4b8f8b49005ac01a011c557e6218941cbb" | ||
| 3211 | + gulp-util@^3.0, gulp-util@^3.0.0, gulp-util@^3.0.4, gulp-util@^3.0.6, gulp-util@^3.0.7, gulp-util@^3.0.8: | ||
| 3212 | + version "3.0.8" | ||
| 3213 | + resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f" | ||
| 3206 | 3214 | dependencies: | |
| 3207 | 3215 | array-differ "^1.0.0" | |
| 3208 | 3216 | array-uniq "^1.0.2" | |
| 3209 | 3217 | beeper "^1.0.0" | |
| 3210 | 3218 | chalk "^1.0.0" | |
| 3211 | - dateformat "^1.0.11" | ||
| 3219 | + dateformat "^2.0.0" | ||
| 3212 | 3220 | fancy-log "^1.1.0" | |
| 3213 | 3221 | gulplog "^1.0.0" | |
| 3214 | 3222 | has-gulplog "^0.1.0" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments