I'm using gulp for a website using Bootstrap that I'm trying to set up. I'm able to successfully run gulp from the node.js command prompt:
gulp running from command line
But no stylesheets are applied to the webpage that loads:
screenshot of what loads errors in console
I've already checked this post: Stylesheet not loaded because of MIME-type and can't find the answer to my problem in it.
This is my code structure:
This is my code:
index.html
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<title>Bootstrap 4 Layout</title>
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway:400,800">
<link rel='stylesheet' href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<script src="/js/jquery.min.js"></script>
<script src="/js/popper.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
</body>
</html>
gulpfile.js
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', gulp.series(function() {
return gulp.src(['node_modules/bootstrap/scss/bootstrap.scss', 'src/scss/*.scss'])
.pipe(sass())
.pipe(gulp.dest("src/css"))
.pipe(browserSync.stream());
}));
// Move the javascript files into our /src/js folder
gulp.task('js', gulp.series(function() {
return gulp.src(['node_modules/bootstrap/dist/js/bootstrap.min.js', 'node_modules/jquery/dist/jquery.min.js', 'node_modules/popper.js/dist/umd/popper.min.js'])
.pipe(gulp.dest("src/js"))
.pipe(browserSync.stream());
}));
// Static Server + watching scss/html files
gulp.task('serve', gulp.series('sass', function() {
browserSync.init({
server: {
baseDir: "./"
},
port: 8080,
open: true,
notify: false
});
gulp.watch(['node_modules/bootstrap/scss/bootstrap.scss', 'src/scss/*.scss'], gulp.series('sass'));
gulp.watch("src/*.html").on('change', browserSync.reload);
}));
gulp.task('default', gulp.series(['js','serve']))
running versions:
npm: 6.9.0
"devDependencies": {
"browser-sync": "^2.26.7",
"gulp": "^4.0.2",
"gulp-cli": "^2.2.0",
"gulp-sass": "^3.1.0"
},
"dependencies": {
"bootstrap": "^4.3.1",
"jquery": "^3.4.1",
"popper.js": "^1.15.0"
}
I have a feeling that the problem might be in gulpfile.js at the bottom here:
browserSync.init({
server: {
baseDir: "./"
},
port: 8080,
open: true,
notify: false
});
Also, I'm trying to follow https://www.youtube.com/watch?v=hnCmSXCZEpU&t=766s for getting bootstrap started and I know that a lot of people from the tutorial have had trouble with this part. Maybe this post can help them too..
EDIT 1
I tried using gulp serve, nothing changed. Here's a link to the edited gulpfile.js
This is what npmjs.com says about gulp serve: