From 060ec1c47aa37f95e07ecc6c419dbee01e572778 Mon Sep 17 00:00:00 2001 From: Alison Monteiro Date: Mon, 7 May 2018 17:05:42 -0300 Subject: [PATCH 1/2] chore(wp): add simple theme initial structure --- src/footer.php | 4 ++++ src/header.php | 12 ++++++++++++ src/index.php | 17 +++++++---------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/footer.php b/src/footer.php index e69de29..4d75d9a 100644 --- a/src/footer.php +++ b/src/footer.php @@ -0,0 +1,4 @@ + + + + diff --git a/src/header.php b/src/header.php index e69de29..8bbc208 100644 --- a/src/header.php +++ b/src/header.php @@ -0,0 +1,12 @@ + + + + GrĂ£o de Milho + + + + + + + + diff --git a/src/index.php b/src/index.php index c98ef5b..6647ae7 100644 --- a/src/index.php +++ b/src/index.php @@ -1,10 +1,7 @@ - - - - - - - - It works! - - + + +
+ +
+ + From 695b6f7cbaff964569690e16b59ccac0b534605a Mon Sep 17 00:00:00 2001 From: Alison Monteiro Date: Mon, 7 May 2018 17:11:35 -0300 Subject: [PATCH 2/2] chore(css): task to load some css from `frist view` inline --- gulpfile.js | 4 +++- package-lock.json | 44 +++++++++++++++++++++++++++++++++++++++++ package.json | 4 +++- src/css/first-view.sass | 9 +++++++++ src/css/main.sass | 1 - src/header.php | 2 ++ tasks/inline-css.js | 22 +++++++++++++++++++++ 7 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 src/css/first-view.sass create mode 100644 tasks/inline-css.js diff --git a/gulpfile.js b/gulpfile.js index dd13ea4..6e6828c 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -47,7 +47,9 @@ gulp.task('watch', () => { const paths = Object.keys(developmentPaths); paths.map(path => { + const task = path; + // Combine each development path with a task - return gulp.watch(gulp.paths[path], [path]); + return gulp.watch(gulp.paths[path], [task]); }); }); diff --git a/package-lock.json b/package-lock.json index 4591a9d..fbbac83 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1166,6 +1166,12 @@ "integrity": "sha1-RqoXUftqL5PuXmibsQh9SxTGwgU=", "dev": true }, + "binaryextensions": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/binaryextensions/-/binaryextensions-1.0.1.tgz", + "integrity": "sha1-HmN0iLNbWL2l9HdL+WpSEqjJB1U=", + "dev": true + }, "bl": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", @@ -5829,6 +5835,17 @@ "integrity": "sha1-OtRCh2PwXidk3sHGfYaNsnVoeBc=", "dev": true }, + "gulp-replace": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/gulp-replace/-/gulp-replace-0.6.1.tgz", + "integrity": "sha1-Eb+Mj85TPjPi9qjy9DC5VboL4GY=", + "dev": true, + "requires": { + "istextorbinary": "1.0.2", + "readable-stream": "2.3.6", + "replacestream": "4.0.3" + } + }, "gulp-sass": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/gulp-sass/-/gulp-sass-4.0.1.tgz", @@ -6927,6 +6944,16 @@ "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", "dev": true }, + "istextorbinary": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/istextorbinary/-/istextorbinary-1.0.2.tgz", + "integrity": "sha1-rOGTVNGpoBc+/rEITOD4ewrX3s8=", + "dev": true, + "requires": { + "binaryextensions": "1.0.1", + "textextensions": "1.0.2" + } + }, "jpegtran-bin": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/jpegtran-bin/-/jpegtran-bin-3.2.0.tgz", @@ -9473,6 +9500,17 @@ "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", "dev": true }, + "replacestream": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/replacestream/-/replacestream-4.0.3.tgz", + "integrity": "sha512-AC0FiLS352pBBiZhd4VXB1Ab/lh0lEgpP+GGvZqbQh8a5cmXVoTe5EX/YeTFArnp4SRGTHh1qCHu9lGs1qG8sA==", + "dev": true, + "requires": { + "escape-string-regexp": "1.0.5", + "object-assign": "4.1.1", + "readable-stream": "2.3.6" + } + }, "request": { "version": "2.85.0", "resolved": "https://registry.npmjs.org/request/-/request-2.85.0.tgz", @@ -10704,6 +10742,12 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, + "textextensions": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/textextensions/-/textextensions-1.0.2.tgz", + "integrity": "sha1-ZUhjk+4fK7A5pgy7oFsLaL2VAdI=", + "dev": true + }, "tfunk": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/tfunk/-/tfunk-3.1.0.tgz", diff --git a/package.json b/package.json index ec17670..c544763 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,9 @@ "start": "npm install && bower install && npm run init", "wp": "gulp wp-install && gulp wp-pre-build && npm run wp:plugins", "wp:dev": "npm run wp && gulp", - "wp:build": "npm run wp && gulp build && npm run assets-version", + "wp:build": "npm run wp && gulp build && npm run assets-version && npm run inline-css", "wp:plugins": "cp -r ./plugins ./wordpress/wp-content", + "inline-css": "gulp inline-css", "assets-version": "gulp asssets-new-version" }, "sasslintConfig": "sass-lint.yml", @@ -46,6 +47,7 @@ "gulp-main-bower-files": "^1.6.2", "gulp-plumber": "^1.2.0", "gulp-rename": "^1.2.2", + "gulp-replace": "^0.6.1", "gulp-sass": "^4.0.1", "gulp-sass-lint": "^1.3.4", "gulp-sourcemaps": "^2.6.4", diff --git a/src/css/first-view.sass b/src/css/first-view.sass new file mode 100644 index 0000000..6ad8631 --- /dev/null +++ b/src/css/first-view.sass @@ -0,0 +1,9 @@ +// tools +@import "tools/mixins" + +// settings +@import "settings/colors" +@import "settings/measures" + +// components +@import "components/header" diff --git a/src/css/main.sass b/src/css/main.sass index a9bf6c7..e1b87f5 100644 --- a/src/css/main.sass +++ b/src/css/main.sass @@ -14,7 +14,6 @@ @import "elements/buttons" // components -@import "components/header" @import "components/footer" @import "components/menu" diff --git a/src/header.php b/src/header.php index 8bbc208..bc17648 100644 --- a/src/header.php +++ b/src/header.php @@ -6,6 +6,8 @@ + + diff --git a/tasks/inline-css.js b/tasks/inline-css.js new file mode 100644 index 0000000..700257e --- /dev/null +++ b/tasks/inline-css.js @@ -0,0 +1,22 @@ +const fs = require('fs'); +const gulp = require('gulp'); +const replace = require('gulp-replace'); +const browserSync = require('browser-sync'); + +gulp.task('inline-css', function() { + const file = `${gulp.paths.stylesDest}/first-view.min.css`; + + if (!fs.existsSync(file)) { + return false; + } + + const inject = /?)>/gi; + const comments = /\/\*[^*]*.*?\*\//; + + const css = fs.readFileSync(file, 'utf8'); + const style = css.replace(comments, '').trim(); + + return gulp.src([`${gulp.paths.pagesDest}**/*.php`]) + .pipe(replace(inject, () => ``)) + .pipe(gulp.dest(gulp.paths.themesWp)); +});