Laravel Elixir 包含 Libsass,因此您不需要 Ruby 来编译来自 Laravel 的 Foundation Sass 文件。你所需要的只是凉亭和 Laravel Elixir。此外,您不需要将文件从文件夹复制bower_components
到resources/assets
文件夹。
首先按照官方说明安装 Elixir。
然后.bowerrc
使用以下内容在 Laravel 项目的根目录中创建文件:
{
"directory": "vendor/bower_components"
}
然后bower.json
使用以下内容在 Laravel 项目的根目录中创建文件:
{
"name": "laravel-and-foundation",
"private": "true",
"dependencies": {
"foundation": "latest"
}
}
然后安装凉亭和基础:
npm install --global bower
bower install # This will install Foundation into vendor/bower_components
然后resources/assets/sass/_settings.scss
使用以下内容创建文件文件:
// Custom settings for Zurb Foundation. Default settings can be found at
// vendor/bower_components/foundation/scss/foundation/_settings.scss
然后resources/assets/sass/app.scss
使用以下内容编辑文件文件:
@import "normalize";
@import "settings";
// Include all foundation
@import "foundation";
// Or selectively include components
// @import
// "foundation/components/accordion",
// "foundation/components/alert-boxes",
// "foundation/components/block-grid",
// "foundation/components/breadcrumbs",
// "foundation/components/button-groups",
// "foundation/components/buttons",
// "foundation/components/clearing",
// "foundation/components/dropdown",
// "foundation/components/dropdown-buttons",
// "foundation/components/flex-video",
// "foundation/components/forms",
// "foundation/components/grid",
// "foundation/components/inline-lists",
// "foundation/components/joyride",
// "foundation/components/keystrokes",
// "foundation/components/labels",
// "foundation/components/magellan",
// "foundation/components/orbit",
// "foundation/components/pagination",
// "foundation/components/panels",
// "foundation/components/pricing-tables",
// "foundation/components/progress-bars",
// "foundation/components/reveal",
// "foundation/components/side-nav",
// "foundation/components/split-buttons",
// "foundation/components/sub-nav",
// "foundation/components/switches",
// "foundation/components/tables",
// "foundation/components/tabs",
// "foundation/components/thumbs",
// "foundation/components/tooltips",
// "foundation/components/top-bar",
// "foundation/components/type",
// "foundation/components/offcanvas",
// "foundation/components/visibility";
使用以下内容配置文件gulpfile.js
:
elixir(function(mix) {
// Compile CSS
mix.sass(
'app.scss', // Source files
'public/css', // Destination folder
{includePaths: ['vendor/bower_components/foundation/scss']}
);
// Compile JavaScript
mix.scripts(
['vendor/modernizr.js', 'vendor/jquery.js', 'foundation.min.js'], // Source files. You can also selective choose only some components
'public/js/app.js', // Destination file
'vendor/bower_components/foundation/js/' // Source files base directory
);
});
要构建只需遵循官方文档:
gulp # Run all tasks...
gulp --production # Run all tasks and minify files
gulp watch # Watch for changes and run all tasks on the fly
您的编译文件将位于public/css/app.css
和public/js/app.js
。
要更新到最新的 Zurb Foundation 版本,只需运行:
bower update