【发布时间】:2016-05-10 04:46:25
【问题描述】:
我想开始使用 Elixir + Gulp。在我的项目中,我只是使用 CSS + JS。
今天,我是这样使用它的:我有一个包含在所有文件中的 dashboard.blade.php。
然后,根据页面,我对每个库都有一个条件包含:
@if (Request::is("tournaments") || Request::is("invites"))
{!! Html::script('js/plugins/tables/footable/footable.min.js') !!}
@endif
@if (Request::is("tournaments/create"))
{!! Html::script('js/plugins/forms/inputs/duallistbox.min.js') !!}
{!! Html::script('js/plugins/pickers/pickadate/picker.js') !!}
{!! Html::script('js/plugins/pickers/pickadate/picker.date.js') !!}
@endif
....
我想要的是使用 elixir,并在 elixir 端做这些事情,这样我就可以简化我的 dashboard.blade.php 并且总是只有 2 个包含:app.css 和 app.js
我只是不知道最好的方法是什么。
有什么想法吗?
编辑1:
在我的 gulp.js 中,我定义了所有页面通用的一般样式:
mix.styles([
'icons/icomoon/styles.css',
'bootstrap.css',
'components.css',
'colors.css'
], 'public/css/app.css');
然后,在我的页面中,我像这样包含它:
{!! Html::style('css/app.css')!!}
我可以用chrome打开文件,所以链接似乎没问题。
但是当我打开我的网站时,一切都出错了,我在 Chrome 控制台中:
Uncaught SyntaxError: Unexpected token <
jquery.min.js:1 Uncaught SyntaxError: Unexpected token <
bootstrap.min.js:1 Uncaught SyntaxError: Unexpected token <
blockui.min.js:1 Uncaught SyntaxError: Unexpected token <
app.js:1 Uncaught SyntaxError: Unexpected token <
pnotify.min.js:1 Uncaught SyntaxError: Unexpected token <
switch.min.js:1 Uncaught SyntaxError: Unexpected token <
(index):1 Failed to decode downloaded font: http://laravel.dev/css/fonts/icomoon.woff?3p0rtw
(index):1 OTS parsing error: invalid version tag
(index):1 Failed to decode downloaded font: http://laravel.dev/css/fonts/icomoon.ttf?3p0rtw
(index):1 OTS parsing error: invalid version tag
我做错了什么???
【问题讨论】:
-
我在特定视图的其他刀片之一中使用
@section('scripts')。因此,如果您有一个特定于tournaments/create视图的刀片,您可以在该刀片中执行@section('scripts')<script src="{{ elixir('....') }}></script>@endsection,这会将脚本添加到您的脚本标签中。 -
样式也一样...
@section('styles') -
但是长生不老药都在 gulp.js 中,不是吗?如何获得统一和缩小的脚本和样式?
-
使用
gulpfile.js,我创建了多个mix.scripts()和mix.styles(),并创建了mix.version()。然后你刚刚吞下的那些“包”可以使用上面的代码获得。 -
好的,所以我 gulp.js,你需要为每个刀片制作 1 个 mix.script,对吗?
标签: javascript php css laravel laravel-elixir