Skip to content

Commit 5a7c588

Browse files
committed
build all the things
1 parent 49b82e8 commit 5a7c588

20 files changed

+202
-23
lines changed

amp-pwa-reader/.eslintrc.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true,
5+
"node": true
6+
},
7+
"extends": "eslint:recommended",
8+
"rules": {
9+
"indent": [
10+
"error",
11+
2
12+
],
13+
"linebreak-style": [
14+
"error",
15+
"unix"
16+
],
17+
"quotes": [
18+
"error",
19+
"single"
20+
],
21+
"semi": [
22+
"error",
23+
"always"
24+
],
25+
"no-else-return": [
26+
"error"
27+
],
28+
"array-bracket-spacing": [
29+
"error",
30+
"always",
31+
{ "singleValue": false }
32+
],
33+
"brace-style": [
34+
"error",
35+
"1tbs"
36+
]
37+
}
38+
}

amp-pwa-reader/.firebaserc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"projects": {
3+
"default": "amp-cards"
4+
}
5+
}

amp-pwa-reader/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.mo
2+
.DS_Store
3+
.sass-cache
4+
.idea
5+
node_modules
6+
7+
dist

amp-pwa-reader/firebase.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"hosting": {
3+
"public": "dist",
4+
"rewrites": [
5+
{
6+
"source": "**",
7+
"destination": "/index.html"
8+
}
9+
]
10+
}
11+
}

amp-pwa-reader/gulpfile.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
let uglifyes = require('uglify-es');
2+
let composer = require('gulp-uglify/composer');
3+
const uglify = composer(uglifyes, console);
4+
const gulp = require('gulp');
5+
const replace = require('gulp-replace');
6+
const plumber = require('gulp-plumber');
7+
const autoprefixer = require('gulp-autoprefixer');
8+
const sass = require('gulp-sass');
9+
const concat = require('gulp-concat');
10+
const browserSync = require('browser-sync').create();
11+
const fs = require('fs');
12+
const del = require('del');
13+
const scriptsGlob = [ 'src/js/**/*.js', 'src/js/init.js' ];
14+
const stylesGlob = 'src/sass/**/*.scss';
15+
const imagesGlob = 'src/img/**/*';
16+
const pagesGlob = 'src/*.html';
17+
18+
gulp.task('copy', function() {
19+
gulp.src(pagesGlob)
20+
.pipe(gulp.dest('dist/'));
21+
22+
gulp.src(imagesGlob)
23+
.pipe(gulp.dest('dist/img'));
24+
});
25+
26+
gulp.task('inline', [ 'sass', 'scripts', 'copy' ], function() {
27+
gulp.src(pagesGlob)
28+
.pipe(replace('/* REPLACED-INLINE-STYLESHEET */', fs.readFileSync('./dist/main.css', 'utf8')))
29+
.pipe(replace('/* REPLACED-INLINE-JAVASCRIPT */', fs.readFileSync('./dist/tmp/app.js', 'utf8')))
30+
.pipe(gulp.dest('dist/'));
31+
});
32+
33+
gulp.task('clean-tmp', ['inline'], function() {
34+
return del([
35+
'dist/tmp',
36+
'dist/main.css'
37+
]);
38+
});
39+
40+
// Sass
41+
gulp.task('sass', function() {
42+
return gulp.src(stylesGlob)
43+
.pipe(plumber())
44+
.pipe(sass({ outputStyle: 'compressed' }))
45+
.pipe(autoprefixer({ browsers: ['> 10%'] }))
46+
.pipe(gulp.dest('dist/'));
47+
});
48+
49+
gulp.task('scripts', function() {
50+
return gulp.src(scriptsGlob)
51+
.pipe(plumber())
52+
.pipe(concat('app.js'))
53+
.pipe(uglify())
54+
.pipe(gulp.dest('dist/tmp/'));
55+
});
56+
57+
// Watch files For changes
58+
gulp.task('watch', function() {
59+
60+
browserSync.init({
61+
server: {
62+
baseDir: 'dist/'
63+
}
64+
});
65+
66+
gulp.watch(scriptsGlob, [ 'scripts', 'clean-tmp' ]);
67+
gulp.watch(stylesGlob, [ 'sass', 'clean-tmp' ]);
68+
gulp.watch(pagesGlob, ['copy']).on('change', browserSync.reload);
69+
70+
});
71+
72+
// Default Task
73+
gulp.task('default', [ 'copy', 'sass', 'scripts' , 'inline', 'clean-tmp', 'watch' ]);
74+
gulp.task('dist', [ 'copy', 'sass', 'scripts', 'inline', 'clean-tmp' ]);

amp-pwa-reader/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "amp-pwa-reader",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "gulpfile.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "Paul Bakaus",
10+
"license": "MIT",
11+
"dependencies": {
12+
"gulp": "*",
13+
"gulp-autoprefixer": "*",
14+
"gulp-plumber": "*",
15+
"gulp-sass": "*",
16+
"gulp-concat": "*",
17+
"uglify-es": "*",
18+
"gulp-uglify": "*",
19+
"gulp-sourcemaps": "*",
20+
"gulp-replace": "*",
21+
"browser-sync": "*",
22+
"del": "*"
23+
}
24+
}
File renamed without changes.

amp-pwa-reader/index.html renamed to amp-pwa-reader/src/index.html

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
66
<title>The Shadow Guardian</title>
77

8-
<link rel="stylesheet" href="css/config.css">
9-
<link rel="stylesheet" href="css/header.css">
10-
<link rel="stylesheet" href="css/nav.css">
11-
<link rel="stylesheet" href="css/card.css">
12-
<link rel="stylesheet" href="css/article.css">
13-
<link rel="stylesheet" href="css/main.css">
8+
<style>/* REPLACED-INLINE-STYLESHEET */</style>
149

1510
<!-- Asynchronously load the AMP-with-Shadow-DOM runtime library. -->
1611
<script async src="https://cdn.ampproject.org/shadow-v0.js"></script>
@@ -79,9 +74,6 @@ <h2>~~~~~~ ~~~ ~~~~~~~~ ~~~ ~~~~~~~~ ~~~~ ~~~~~</h2>
7974

8075
</div>
8176

82-
<script src="js/Nav.js"></script>
83-
<script src="js/Card.js"></script>
84-
<script src="js/Article.js"></script>
85-
<script src="js/init.js"></script>
77+
<script>/* REPLACED-INLINE-JAVASCRIPT */</script>
8678
</body>
8779
</html>

amp-pwa-reader/js/Article.js renamed to amp-pwa-reader/src/js/Article.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Article {
5050
// TODO; copy stylesheet from host over directly
5151
var stylesheet = document.createElement('link');
5252
stylesheet.setAttribute('rel', 'stylesheet');
53-
stylesheet.setAttribute('href', 'css/card.css');
53+
stylesheet.setAttribute('href', '/inline.css');
5454
this.doc.body.append(stylesheet);
5555

5656
}

amp-pwa-reader/js/Card.js renamed to amp-pwa-reader/src/js/Card.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var itemsContainer = document.querySelector('main');
22
var header = document.querySelector('header');
3-
var menuButton = document.querySelector('label.hamburger');
3+
var menuButton = document.querySelector('.hamburger');
44

55
/*
66
* Card

0 commit comments

Comments
 (0)