I think it is a good idea to move dependencies from bower to npm as we already use npm for dev dependencies. Bower just seems like a unnecessary step at this point. Here are the changes I did when testing this out on a fresh sage 8 install.
Remove dependecies from bower.json
{
"name": "sage",
"homepage": "https://roots.io/sage/",
"authors": [
"Ben Word <ben@benword.com>"
],
"license": "MIT",
"private": true
}
Add dependecies and remove wiredep devDependencies from package.json (Here I also updated all dev dependencies) and remove bower from the “scripts”.
{
"name": "sage",
"version": "8.5.4",
"author": "Ben Word <ben@benword.com>",
"homepage": "https://roots.io/sage/",
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/roots/sage.git"
},
"bugs": {
"url": "https://github.com/roots/sage/issues"
},
"licenses": [
{
"type": "MIT",
"url": "http://opensource.org/licenses/MIT"
}
],
"scripts": {
"build": "gulp",
"start": "gulp watch",
"jshint": "gulp jshint",
"jscs": "jscs gulpfile.js assets/scripts/*.js"
},
"engines": {
"node": ">= 4.5"
},
"dependencies": {
"bootstrap": "v4.1.0",
"jquery": "^3.3.1"
},
"devDependencies": {
"asset-builder": "^1.1.0",
"browser-sync": "^2.23.7",
"del": "^3.0.0",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^5.0.0",
"gulp-changed": "^3.2.0",
"gulp-concat": "^2.6.1",
"gulp-cssnano": "^2.1.3",
"gulp-flatten": "0.4.0",
"gulp-if": "^2.0.2",
"gulp-imagemin": "^4.1.0",
"gulp-jshint": "^2.1.0",
"gulp-less": "^4.0.0",
"gulp-plumber": "^1.2.0",
"gulp-rename": "^1.2.2",
"gulp-rev": "^8.1.1",
"gulp-sass": "^4.0.1",
"gulp-sourcemaps": "^2.6.4",
"gulp-uglify": "^3.0.0",
"imagemin-pngcrush": "^5.1.0",
"jshint": "^2.9.5",
"jshint-stylish": "^2.2.1",
"lazypipe": "^1.0.1",
"merge-stream": "^1.0.1",
"minimist": "^1.2.0",
"run-sequence": "^2.2.1",
"traverse": "^0.6.6"
}
}
Change .bowerrc (This way we pretend to use bower to make the build process happy)
{
"directory": "node_modules"
}
Then in gulpfile.js we can remove this part
// ### Wiredep
// `gulp wiredep` - Automatically inject Less and Sass Bower dependencies. See
// https://github.com/taptapship/wiredep
gulp.task('wiredep', function() {
var wiredep = require('wiredep').stream;
return gulp.src(project.css)
.pipe(wiredep())
.pipe(changed(path.source + 'styles', {
hasChanged: changed.compareSha1Digest
}))
.pipe(gulp.dest(path.source + 'styles'));
});
and remove wiredep from the styles task so it looks like this:
// ### Styles
// `gulp styles` - Compiles, combines, and optimizes project CSS.
// By default this task will only log a warning if a precompiler error is
// raised. If the `--production` flag is set: this task will fail outright.
gulp.task('styles', function() {
var merged = merge();
manifest.forEachDependency('css', function(dep) {
var cssTasksInstance = cssTasks(dep.name);
if (!enabled.failStyleTask) {
cssTasksInstance.on('error', function(err) {
console.error(err.message);
this.emit('end');
});
}
merged.add(gulp.src(dep.globs, {base: 'styles'})
.pipe(plumber({errorHandler: onError}))
.pipe(cssTasksInstance));
});
return merged
.pipe(writeToManifest('styles'));
});
Manually add bootstrap styles in main.scss as they are no longer automatically added.
@import "common/variables";
@import "./../../node_modules/bootstrap/scss/bootstrap";
@import "common/global";
@import "components/buttons";
@import "components/comments";
@import "components/forms";
@import "components/grid";
@import "components/wp-classes";
@import "layouts/header";
@import "layouts/sidebar";
@import "layouts/footer";
@import "layouts/pages";
@import "layouts/posts";
@import "layouts/tinymce";
Change assets/manifest.json to no longer depend on bower to locate files
{
"dependencies": {
"main.js": {
"files": [
"./../node_modules/bootstrap/dist/js/bootstrap.js",
"scripts/main.js"
]
},
"main.css": {
"files": [
"styles/main.scss"
]
},
"customizer.js": {
"files": [
"scripts/customizer.js"
]
},
"jquery.js": {
"files": [
"./../node_modules/jquery/dist/jquery.js"
]
}
},
"config": {
"devUrl": "http://example.test"
}
}
I also added a .jshintignore file to remove warnings about bootstrap
node_modules