-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🏥 Fix Unstable Selectors, Background Images, and More (#8)
* Copy timeline into a separate window * Shorten document title below max filename length * Fix background images not showing up on print * Build Process FTW * Fix timestamp element not matching in other languages * 🔥 Fix unstable timeline selector * Make timestamp regex even more robust (works in Japanese now too) * Improve media sizing to fit within the page * Add 50ms delay to help reduce risk of rate limits * Add zip to default gulp command (easier 1-step builds) * Add v2.1.0 notes * Fix v2.1.0 package.json version and changelog date * Update package-lock.json * Changelog footnotes
- Loading branch information
1 parent
179204c
commit 35bdc32
Showing
8 changed files
with
532 additions
and
145 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
*.psd | ||
*.zip | ||
build/ | ||
dist/ | ||
|
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 |
---|---|---|
@@ -1,8 +1,69 @@ | ||
const gulp = require('gulp'); | ||
const { dest, parallel, series, src, watch } = require('gulp'); | ||
const clean = require('postcss-clean'); | ||
const fs = require('fs'); | ||
const postcss = require('gulp-postcss'); | ||
const prefixer = require('postcss-prefix-selector'); | ||
const replace = require('gulp-replace'); | ||
const zip = require('gulp-zip'); | ||
|
||
exports.default = () => ( | ||
gulp.src('src/*') | ||
.pipe(zip('chrome-twitter-print-styles.zip')) | ||
.pipe(gulp.dest('dist')) | ||
/** | ||
* Process CSS to work with both default Twitter print styles, | ||
* and the custom print screen that we open in a new window. | ||
*/ | ||
function copy() { | ||
return src('src/*') | ||
.pipe(dest('dist/')); | ||
} | ||
exports.copy = copy; | ||
|
||
/** | ||
* Process CSS to work with both default Twitter print styles, | ||
* and the custom print screen that we open in a new window. | ||
*/ | ||
const css = parallel( | ||
// Wrap everything in a print media query so we can apply | ||
// it to Twitter's default print styles. | ||
function defaultPrintCSS() { | ||
return src('src/index.css') | ||
.pipe(replace('/* BEGIN */', '@media print {')) | ||
.pipe(replace('/* END */', '}')) | ||
.pipe(dest('dist/')); | ||
}, | ||
// Prefix everything with a custom ID, then compress it to | ||
// fit in a <style> tag for the custom print window. | ||
function customPrintCSS() { | ||
return src('src/index.css') | ||
.pipe(postcss([ | ||
prefixer({ prefix: '#twitter-print-styles' }), | ||
clean() | ||
])) | ||
.pipe(dest('build/')); | ||
} | ||
); | ||
exports.css = css; | ||
|
||
/** | ||
* Process JS to include our CSS in the custom print window. | ||
*/ | ||
function js() { | ||
return src('src/content.js') | ||
.pipe(replace('/* STYLES */', fs.readFileSync('build/index.css', 'utf8'))) | ||
.pipe(dest('dist/')); | ||
} | ||
exports.js = js; | ||
|
||
/** | ||
* ZIP final build for publishing on the Chrome Web Store. | ||
*/ | ||
function zipTask() { | ||
return src('dist/*') | ||
.pipe(zip('chrome-twitter-print-styles.zip')) | ||
.pipe(dest('./')); | ||
} | ||
exports.zip = zipTask; | ||
|
||
// Tasks | ||
exports.default = series(copy, css, js, zipTask); | ||
|
||
// Watch | ||
exports.watch = () => watch('src/*', series(copy, css, js)); |
Oops, something went wrong.