Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
try use gulp to do source inline instead of using jade
test
  • Loading branch information
irvin committed Oct 6, 2018
commit 6f06a0940ee75d7a4f27ea081e6417f3cbcbf176
8 changes: 3 additions & 5 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
git checkout gh-pages
git merge master
gulp build
rm index.html
rm 404.html
cp _public/*.html ./
git add .
gulp deploy
git add index.html
git add 404.html
git commit -m 'deploy'
echo "I'll no longer pull and push for you, please push with causion on which remote you'd like to."
25 changes: 25 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import path from 'path';
import sass from 'gulp-sass';
import jade from 'gulp-jade';
import plumber from 'gulp-plumber';
import inlinesource from 'gulp-inline-source';
import debug from 'gulp-debug-streams';
import replace from 'gulp-replace';

const app = express();

Expand Down Expand Up @@ -57,6 +60,28 @@ gulp.task('watch', () => {
gulp.watch('js/*js', ['js']);
});

gulp.task('inlinesource', function () {
return gulp.src(`${build_path}/index.html`)
// .pipe(debug())
// .pipe(debug(path.resolve(`${build_path}`)))
.pipe(replace(/<script type="text\/javascript" src="\/(js\/index.js)"><\/script>/g, '<div id="script"><script inline type="text/javascript" src="$1"></script></div>'))
/* // uncommand to inline all scripts / css
.pipe(replace(/<script type="text\/javascript" src="\/(.*?.js)">/g, '<script inline type="text/javascript" src="$1">'))
.pipe(replace(/<link rel="stylesheet" (type="text\/css" )??href="\/(.*?.css)">/g, '<link inline rel="stylesheet" type="text/css" href="$2">'))
*/
/* // for debug
.pipe(replace(/<link rel="stylesheet" (type="text\/css" )??href="\/(.*?.css)">/g, function(match, p1, offset, string) { console.log(match); }))
.pipe(replace(/<script type="text\/javascript" src="\/(.*?.js)">/g, function(match, p1, offset, string) { console.log(match); }))
*/
.pipe(inlinesource({
compress: false,
rootpath: path.resolve(`${build_path}`)
}))
.pipe(gulp.dest(`${build_path}/out`));
});

gulp.task('build', ['jade', 'sass', 'js', 'assets']);
gulp.task('dev', ['build', 'server', 'watch']);
gulp.task('deploy', ['build', 'inlinesource']);

gulp.task('default', ['build']);
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"engines": {
"node": "0.10.x"
},
"dependencies": {},
"dependencies": {
"gulp-debug-streams": "^3.0.0"
},
"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
Expand All @@ -25,9 +27,11 @@
"express": "^4.13.4",
"gulp": "^3.9.1",
"gulp-babel": "^8.0.0",
"gulp-inline-source": "^3.2.0",
"gulp-jade": "^1.1.0",
"gulp-plumber": "^1.1.0",
"gulp-refresh": "^1.1.0",
"gulp-replace": "^1.0.0",
"gulp-sass": "^2.2.0",
"gulp-util": "^3.0.8"
},
Expand Down