From 7ffffdb3a20099926c64551bc8c8975b821e0dc9 Mon Sep 17 00:00:00 2001 From: iceStone Date: Sun, 24 Apr 2016 23:37:01 +0800 Subject: [PATCH] remove babel && update npm --- .babelrc | 1 - README.md | 90 +++++++++++++++------------------------------------- gulpfile.js | 30 ++++++++---------- package.json | 20 ++++++------ 4 files changed, 50 insertions(+), 91 deletions(-) diff --git a/.babelrc b/.babelrc index 1f1c3eb..c13c5f6 100644 --- a/.babelrc +++ b/.babelrc @@ -1,4 +1,3 @@ { "presets": ["es2015"] } - 1) diff --git a/README.md b/README.md index 8140886..2fdc669 100644 --- a/README.md +++ b/README.md @@ -1,80 +1,42 @@ -# Micua Home - -## Install -- npm i babel-core babel-preset-es2015 browser-sync del gulp gulp-autoprefixer gulp-cache gulp-cssnano gulp-eslint gulp-gh-pages gulp-htmlmin gulp-if gulp-imagemin gulp-load-plugins gulp-plumber gulp-reversion gulp-sass gulp-size gulp-sourcemaps gulp-uglify gulp-useref main-bower-files wiredep --save-dev - +# Micua Home(a webapp template) +[![Build Status](https://secure.travis-ci.org/Micua/Home.svg?branch=master)](http://travis-ci.org/Micua/Home) -- npm i browser-sync del gulp gulp-autoprefixer gulp-cache gulp-cssnano gulp-eslint gulp-gh-pages gulp-htmlmin gulp-if gulp-imagemin gulp-load-plugins gulp-plumber gulp-reversion gulp-sass gulp-size gulp-sourcemaps gulp-uglify gulp-useref main-bower-files wiredep --save-dev +## Features +Please see our [gulpfile](app/templates/gulpfile.babel.js) for up to date information on what we support. +* CSS Autoprefixing +* Built-in preview server with BrowserSync +* Automagically compile Sass with [libsass](http://libsass.org) +* Automagically lint your scripts +* Map compiled CSS to source stylesheets with source maps +* Awesome image optimization +* Automagically wire-up dependencies installed with [Bower](http://bower.io) +* The gulpfile makes use of [ES2015 features](https://babeljs.io/docs/learn-es2015/) by using [Babel](https://babeljs.io) -var fs = require('fs'); -var path = require('path'); -var crypto = require('crypto'); -var Buffer = require('buffer').Buffer; -var gutil = require('gulp-util'); -var PluginError = gutil.PluginError; -var map = require('event-stream').map; +*For more information on what this generator can do for you, take a look at the [gulp plugins](app/templates/_package.json) used in our `package.json`.* -var FILE_DECL = /(href=|src=|url\()(['|"])([^\s>"'.]+?(\.css|\.js|\.png|\.gif|\.jpeg|\.jpg))(['|"])/gi; -var revPlugin = function revPlugin() { +## libsass - return map(function(file, cb) { +Keep in mind that libsass is feature-wise not fully compatible with Ruby Sass. Check out [this](http://sass-compatibility.github.io) curated list of incompatibilities to find out which features are missing. - var contents; - var lines; - var i, length; - var line; - var groups; - var dependencyPath; - var data, hash; +If your favorite feature is missing and you really need Ruby Sass, you can always switch to [gulp-ruby-sass](https://github.com/sindresorhus/gulp-ruby-sass) and update the `styles` task in gulpfile accordingly. - if (!file) { - throw new PluginError('gulp-rev-append', 'Missing file option for gulp-rev-append.'); - } - if (!file.contents) { - throw new PluginError('gulp-rev-append', 'Missing file.contents required for modifying files using gulp-rev-append.'); - } +## Getting Started - contents = file.contents.toString(); - lines = contents.split('\n'); - length = lines.length; +- Run `gulp serve` to preview and watch for changes +- Run `bower install --save ` to install frontend dependencies +- Run `gulp serve:test` to run the tests in the browser +- Run `gulp` to build your webapp for production +- Run `gulp serve:dist` to preview the production build - for (i = 0; i < length; i++) { - line = lines[i]; - groups = FILE_DECL.exec(line); - if (groups && groups.length > 1) { - // are we an "absoulte path"? (e.g. /js/app.js) - var normPath = path.normalize(groups[3]); - if (normPath.indexOf(path.sep) === 0) { - dependencyPath = path.join(file.base, normPath); - } else { - dependencyPath = path.resolve(path.dirname(file.path), normPath); - } - try { - data = fs.readFileSync(dependencyPath); - hash = crypto.createHash('md5'); - hash.update(data.toString(), 'utf8'); - line = line.replace(groups[4], groups[4] + '?v=' + hash.digest('hex')); - console.log(line); - } catch (e) { - // fail silently. - console.log(e); - } - } - lines[i] = line; - FILE_DECL.lastIndex = 0; - } - file.contents = new Buffer(lines.join('\n')); - cb(null, file); +## License - }); - -}; - -module.exports = revPlugin; +ISC © [iceStone](https://github.com/Micua/) +## Install +- npm i babel-core babel-preset-es2015 browser-sync del gulp gulp-autoprefixer gulp-cache gulp-cssnano gulp-eslint gulp-gh-pages gulp-htmlmin gulp-if gulp-imagemin gulp-load-plugins gulp-plumber gulp-reversion gulp-sass gulp-size gulp-sourcemaps gulp-uglify gulp-useref main-bower-files wiredep --save-dev diff --git a/gulpfile.js b/gulpfile.js index 235b39f..fe1b2f8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -8,12 +8,12 @@ const gulp = require("gulp"); const gulpLoadPlugins = require("gulp-load-plugins"); -const browserSync = require("browser-sync"); const del = require("del"); + +const bs = require("browser-sync").create(); const wiredep = require("wiredep").stream; const plugins = gulpLoadPlugins(); -const reload = browserSync.reload; gulp.task('styles', () => { return gulp.src('src/styles/*.scss') @@ -24,26 +24,24 @@ gulp.task('styles', () => { precision: 10, // includePaths: [''] }).on('error', plugins.sass.logError)) - .pipe(plugins.autoprefixer({ - browsers: ['last 2 version'] - })) - .pipe(plugins.sourcemaps.write()) + // .pipe(plugins.autoprefixer({ + // browsers: ['last 2 version'] + // })) + .pipe(plugins.sourcemaps.write('.')) .pipe(gulp.dest('temp/styles')) - .pipe(reload({ - stream: true - })); + .pipe(bs.stream({ match: "**/*.css" })); }); function lint(files, options) { return () => { return gulp.src(files) - .pipe(reload({ + .pipe(bs.reload({ stream: true, once: true })) .pipe(plugins.eslint(options)) .pipe(plugins.eslint.format()) - .pipe(plugins.if(!browserSync.active, plugins.eslint.failAfterError())); + .pipe(plugins.if(!bs.active, plugins.eslint.failAfterError())); }; } const testLintOptions = { @@ -122,7 +120,7 @@ gulp.task('extras', () => { gulp.task('clean', del.bind(null, ['temp', 'dist', '.publish'])); gulp.task('serve', ['styles', 'fonts'], () => { - browserSync({ + bs.init({ notify: false, port: 2015, server: { @@ -138,7 +136,7 @@ gulp.task('serve', ['styles', 'fonts'], () => { 'src/scripts/**/*.js', 'src/images/**/*', 'temp/fonts/**/*' - ]).on('change', reload); + ]).on('change', bs.reload); gulp.watch('src/styles/**/*.scss', ['styles']); gulp.watch('src/fonts/**/*', ['fonts']); @@ -146,7 +144,7 @@ gulp.task('serve', ['styles', 'fonts'], () => { }); gulp.task('serve:dist', () => { - browserSync({ + bs.init({ notify: false, port: 2015, server: { @@ -156,7 +154,7 @@ gulp.task('serve:dist', () => { }); gulp.task('serve:test', () => { - browserSync({ + bs.init({ notify: false, port: 2015, ui: false, @@ -168,7 +166,7 @@ gulp.task('serve:test', () => { } }); - gulp.watch('test/spec/**/*.js').on('change', reload); + gulp.watch('test/spec/**/*.js').on('change', bs.reload); gulp.watch('test/spec/**/*.js', ['lint:test']); }); diff --git a/package.json b/package.json index 4149c52..2b13e0c 100644 --- a/package.json +++ b/package.json @@ -6,30 +6,30 @@ "node": ">=0.12.0" }, "scripts": { - "watch": "browser-sync start --server --no-notify --files='*.html, scripts/*.js, styles/*.css'" + "watch": "browser-sync start --server --no-notify --files=\"*.html, scripts/*.js, styles/*.css\"" }, "devDependencies": { - "browser-sync": "^2.11.1", + "browser-sync": "^2.12.3", "del": "^2.2.0", "gulp": "^3.9.1", "gulp-autoprefixer": "^3.1.0", - "gulp-cache": "^0.4.2", - "gulp-cssnano": "^2.1.1", + "gulp-cache": "^0.4.4", + "gulp-cssnano": "^2.1.2", "gulp-eslint": "^2.0.0", "gulp-gh-pages": "^0.5.4", "gulp-htmlmin": "^1.3.0", "gulp-if": "^2.0.0", "gulp-imagemin": "^2.4.0", - "gulp-load-plugins": "^1.2.0", + "gulp-load-plugins": "^1.2.2", "gulp-plumber": "^1.1.0", "gulp-reversion": "^1.0.1", - "gulp-sass": "^2.2.0", - "gulp-size": "^2.0.0", - "gulp-sourcemaps": "^1.6.0", + "gulp-sass": "^2.3.1", + "gulp-size": "^2.1.0", + "gulp-sourcemaps": "^2.0.0-alpha", "gulp-uglify": "^1.5.3", - "gulp-useref": "^3.0.7", + "gulp-useref": "^3.0.8", "main-bower-files": "^2.11.1", - "wiredep": "^3.0.0" + "wiredep": "^4.0.0" }, "eslintConfig": { "env": {