-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from pipocadigital/proposal-inline-css
Task to load custom critical/first-view css as Internal
- Loading branch information
Showing
9 changed files
with
106 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// tools | ||
@import "tools/mixins" | ||
|
||
// settings | ||
@import "settings/colors" | ||
@import "settings/measures" | ||
|
||
// components | ||
@import "components/header" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<script src="<?php echo get_bloginfo('template_url') ?>/js/libs.min.js" defer></script> | ||
<script src="<?php echo get_bloginfo('template_url') ?>/js/main.min.js" defer></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Grão de Milho</title> | ||
|
||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> | ||
|
||
<link inject-first-view-css href="<?php echo get_bloginfo('template_url') ?>/css/first-view.min.css" rel="stylesheet"> | ||
|
||
<link href="<?php echo get_bloginfo('template_url') ?>/css/libs.min.css" rel="stylesheet"/> | ||
<link href="<?php echo get_bloginfo('template_url') ?>/css/main.min.css" rel="stylesheet"/> | ||
</head> | ||
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title></title> | ||
</head> | ||
<body> | ||
<strong>It works!</strong> | ||
</body> | ||
</html> | ||
<?php get_header() ?> | ||
|
||
<main> | ||
|
||
</main> | ||
|
||
<?php get_footer() ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = /<link\s*inject-first-view-css\s*(.*\>?)>/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, () => `<style>${style}</style>`)) | ||
.pipe(gulp.dest(gulp.paths.themesWp)); | ||
}); |