以下がコードです。(念のため丸々コピペしているので、sassなどの記述もありますが、今回はEJSについて聞きたいです。)
EJSをhtmlで吐き出すように書いているつもりですが、ejsでしかコンパイルされません。
gulpfile
1const gulp = require("gulp"); 2const sass = require("gulp-sass"); 3const ejs = require("gulp-ejs"); 4const plumber = require('gulp-plumber'); 5const browserSync = require('browser-sync'); 6const glob = require('gulp-sass-glob'); 7const rename = require('gulp-rename'); 8 9gulp.task('default',function(){ 10 gulp.watch( "./scss/**/*.scss", gulp.series( "sass" ) ); 11 gulp.watch( "./ejs/**/*.ejs", gulp.series( "ejs" ) ); 12}); 13 14gulp.task('sass',function(){ 15 var option = { 16 outputStyle: 'expanded', 17 }; 18 return gulp.src('./scss/**/*.scss') 19 .pipe(plumber()) 20 .pipe(glob()) 21 .pipe(sass(option)) 22 .pipe(gulp.dest('./')) 23 .pipe(browserSync.stream()); 24}); 25 26gulp.task( "ejs", function () { 27 return gulp.src('./ejs/**/*.ejs') 28 .pipe(plumber()) 29 .pipe(ejs({}, {}, { ext: '.html' })) 30 .pipe( gulp.dest( './' ) ) 31 .pipe(browserSync.stream()) 32 .pipe(rename({ 33 extname: ".html" 34 })) 35}); 36
root/
root/gulpfile.js
root/scss/main.scss
root/ejs/index.ejs
...(その他諸々)
▼コンパイルされたファイル
root/main.css
root/index.html
ファイルの中身は無事コンパイルされているのですが、htmlに吐き出させるコードだけ機能させることができません。ちなみにsassの記述はコンパイルとcssへの拡張子変更もうまく行っています。
ejsに関して、どこを変更すれば良いのでしょうか。。
また、「こう書いた方がいい」と言った部分などあれば、アドバイスをいただきたいのです。
どうか、よろしくお願いします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/22 11:38
2019/05/22 12:14
2019/05/23 01:23