如何在 Laravel 中使用 Lumx 和 Elixir?

How to use Lumx in Laravel with Elixir?

我遵循了 中提供的一个答案,但我无法使用 Gulp.

成功编译 lumx 的 SCSS 文件

有人知道如何解决这个问题吗?

我的 app.scss 包含这个:

@import "../../../bower_components/mdi/scss/materialdesignicons";
@import "../../../bower_components/lumx/dist/scss/lumx";

在 运行 gulp 之后,我收到此错误:

gulp-notify: [Laravel Elixir] Sass Compilation Failed: bower_components\lumx\dist\scss\_lumx.scss
    Error: File to import not found or unreadable: bourbon
           Parent style sheet: D:/laragon1.0.6/www/task-manager/bower_components/lumx/dist/scss/_lumx.scss
            on line 5 of bower_components/lumx/dist/scss/_lumx.scss
    >> @import "bourbon";

_lumx.scss 文件包含

@import "bourbon";
@import "materialdesignicons";

@import "settings/colors";
@import "settings/defaults";
@import "settings/responsive";

我的 bower_components 文件夹位于我的 Laravel 应用程序的根文件夹中。 所有 javascript 文件都适用于 Elixir 任务,但只有 scss 文件有问题。

我可以将 lumx 与 laravel 集成。

进入项目文件夹

npm install

bower init

bower install lumx --save

  • 配置gulpfile.js

elixir((mix) => {
    //mix.sass('app.scss');
    //mix.webpack('app.js');
    mix.styles('./bower_components/lumx/dist/lumx.css');
    mix.styles('./bower_components/mdi/css/materialdesignicons.css');
    mix.scripts('./bower_components/jquery/dist/jquery.js');
    mix.scripts('./bower_components/velocity/velocity.js');
    mix.scripts('./bower_components/moment/min/moment-with-locales.js');
    mix.scripts('./bower_components/angular/angular.js');
    mix.scripts('./bower_components/lumx/dist/lumx.js');
    mix.copy('./bower_components/mdi/fonts', 'public/fonts');

});

  • 在 resources/views/test.blade.php 中创建 test.blade.php 并配置

<!DOCTYPE html>
<html lang="en" ng-app = "myModule">
<head>
<meta charset="UTF-8">
<title>Laravel Lumx</title>
<link rel="stylesheet" href="{{ asset('css/lumx.css') }}">
<link rel="stylesheet" href="{{ asset('css/materialdesignicons.css') }}">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:300,400,500,700">
</head>
  <body>
    <div class="p+">
    Hello
  </div>
    <div class="p+">
      <lx-button lx-type="raised">Button</lx-button>
      <lx-button lx-type="flat">Button</lx-button>
      <lx-button lx-type="fab"><i class="mdi mdi-plus"></i></lx-button>
      <lx-button lx-type="icon"><i class="mdi mdi-plus"></i></lx-button>
    </div>
    
    <div class="p+">
      <lx-switch ng-model="vm.switches.colors.blue" lx-color="blue">Blue switch</lx-switch>
      <lx-switch ng-model="vm.switches.colors.green" lx-color="green" class="mt+">Green switch</lx-switch>
      <lx-switch ng-model="vm.switches.colors.orange" lx-color="orange" class="mt+">Orange switch</lx-switch>
      <lx-switch ng-model="vm.switches.colors.red" lx-color="red" class="mt+">Red switch</lx-switch>
    </div>

    <script src="{{ asset('js/jquery.js') }}"></script>
    <script src="{{ asset('js/velocity.js') }}"></script>
    <script src="{{ asset('js/moment-with-locales.js') }}"></script>
    <script src="{{ asset('js/angular.js') }}"></script>
    <script src="{{ asset('js/lumx.js') }}"></script>
    <script>
      angular.module('myModule', ['lumx']);
    </script>

  </body>
</html>

  • 配置routes/web.php

Route::get('/', function () {
    return view('test');
});

  • 现在运行执行gulp命令,在浏览器中打开项目就可以看到this

  • 你可以把所有的js和ccs打包在一个文件里

config the gulpfile.js

elixir((mix) => {
    //mix.sass('app.scss');
    //mix.webpack('app.js');
    mix.styles([
      './bower_components/lumx/dist/lumx.css',
      './bower_components/mdi/css/materialdesignicons.css'
  ], 'public/css/lumxall.css');
    mix.scripts([
      './bower_components/jquery/dist/jquery.js',
      './bower_components/velocity/velocity.js',
      './bower_components/moment/min/moment-with-locales.js',
      './bower_components/angular/angular.js',
      './bower_components/lumx/dist/lumx.js'
    ], 'public/js/lumxall.js');
    mix.copy('./bower_components/mdi/fonts', 'public/fonts');

});

  • 更新文件test.blade.php

<!DOCTYPE html>
<html lang="en" ng-app = "myModule">
<head>
<meta charset="UTF-8">
<title>Laravel Lumx</title>
<link rel="stylesheet" href="{{ asset('css/lumxall.css') }}">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:300,400,500,700">
</head>
  <body>
    <div class="p+">
    Hola
  </div>
    <div class="p+">
      <lx-button lx-type="raised">Button</lx-button>
      <lx-button lx-type="flat">Button</lx-button>
      <lx-button lx-type="fab"><i class="mdi mdi-plus"></i></lx-button>
      <lx-button lx-type="icon"><i class="mdi mdi-plus"></i></lx-button>
    </div>

    <div class="p+">
      <lx-switch ng-model="vm.switches.colors.blue" lx-color="blue">Blue switch</lx-switch>
      <lx-switch ng-model="vm.switches.colors.green" lx-color="green" class="mt+">Green switch</lx-switch>
      <lx-switch ng-model="vm.switches.colors.orange" lx-color="orange" class="mt+">Orange switch</lx-switch>
      <lx-switch ng-model="vm.switches.colors.red" lx-color="red" class="mt+">Red switch</lx-switch>
    </div>


    <script src="{{ asset('js/lumxall.js') }}"></script>
    <script>
      angular.module('myModule', ['lumx']);
    </script>

  </body>
</html>

  • 和运行命令再次gulp

  • For angular-material, material design lite, Material Design for Bootstrap and other framework, this it's valid

  • 源代码在Github