Reputation: 7553
I added bootstrap-sass-official
to my bower dependencies into bower_components
.
I compiled and added bootstrap css files to public
this way (in gulpfile.js
):
var paths = {
'bootstrap': 'bower_components/bootstrap-sass-official/assets/',
'jquery': 'bower_components/jquery/dist/'
};
elixir(function(mix) {
mix.sass('app.scss', null, {includePaths: [paths.bootstrap + 'stylesheets/']});
});
In app.scss
there is a line @import '_bootstrap';
. And css files are compiled and they work.
How can I add bootstrap fonts and scripts to the page?
Upvotes: 3
Views: 4433
Reputation: 5566
My solution, I'm quite proud of.
/gulpfile.js
var elixir = require('laravel-elixir');
// Set your Bower target directory below.
var bowerDir = './vendor/bower_components';
// Helper function.
function bower(pkg, path) {
return [bowerDir, pkg, path].join('/');
}
elixir(function (mix) {
// Styles
mix.sass('app.scss', null, {includePaths: [bowerDir]});
// Fonts
mix.copy(bower('bootstrap-sass', 'assets/fonts/**'), 'public/build/fonts');
// Scripts
mix.scripts([
bower('jquery', 'dist/jquery.min.js'),
bower('bootstrap-sass', 'assets/javascripts/bootstrap.min.js')
]);
// Versioning
mix.version([
'css/app.css',
'js/all.js'
]);
});
/resources/assets/sass/app.scss
@import "bootstrap-sass/assets/stylesheets/bootstrap";
body {
font: 100% Helvetica, sans-serif;
color: #333;
}
Bonus tip for PhpStorm
Set up bowerDir
as Resource Root in PhpStorm. This way you will get rid off warnings.
Use Ctrl+Space to show up path autocompletion.
Upvotes: 1
Reputation: 7553
I found out a solution:
mix.scripts(
'*',
'resources/assets/javascripts',
'public/js/app.js'
);
mix.scripts(
[
paths.jquery + 'jquery.js',
paths.bootstrap + 'javascripts/bootstrap.js'
],
'public/js/dependencies.js',
'bower_components'
);
mix.copy(paths.bootstrap + 'fonts/bootstrap/', "public/fonts/");
Upvotes: 1