Giter VIP home page Giter VIP logo

laravel-elixir-wiredep's Issues

Path of bower_component is wrong

After wiredep, the template would be:

<!-- bower:css -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<!-- endbower -->

But the full URL of bootstrap.css would be http://homestead.app/auth/bower_components/bootstrap/dist/css/bootstrap.css when I browse http://homestead.app/auth/login, it is wrong.

I found the pattern of ignorePath should be /(\..\/)*public/, not /(\..\/)*public\//, I fixed it in gulpfile.

Do I miss something?

gulp --production

Your script on production gulp --production should concat and minify the scripts and styles.
Nice plugin, but still useless in real world.

I'm happy to announce :)

Yes I did it :) And yes its works.
Still waiting for official support on jonkemp/useref#7
and your updates. So I hope you will bring back the old options and by default return assets with asset() function.

My package.json

{
  "private": true,
  "devDependencies": {
    "gulp": "^3.8.8"
  },
  "dependencies": {
    "laravel-elixir": "^4.0.0",
    "laravel-elixir-useref": "^1.2.1",
    "laravel-elixir-wiredep": "^2.1.0",
    "useref": "git+https://github.com/CodersAKL/useref.git#master"
  }
}

My gulp.js file

require('laravel-elixir');
require('laravel-elixir-wiredep');
require('laravel-elixir-useref');

var options = {
    fileTypes: {
        php: {
            block: /(([ \t]*)<!--\s*bower:*(\S*)\s*-->)(\n|\r|.)*?(<!--\s*endbower\s*-->)/gi,
            detect: {
                js: /<script.*src=['"]([^'"]+)/gi,
                css: /<link.*href=['"]([^'"]+)/gi
            },
            replace: {
                js: '<script src="{{ asset(\'{{filePath}}\') }}"></script>',
                css: '<link rel="stylesheet" href="{{ asset(\'{{filePath}}\') }}" />'
            }
        }
    }
};

elixir(function (mix) {
    mix
        .sass('app.scss')
        .browserify('app.js')
        .wiredep('php', {src: 'layouts/app.blade.php'}, options)
        .useref()
        .version(['js/vendors.min.js', 'css/vendors.min.css']);
});

My layouts/app.blade.php file

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Laravel</title>
    @if ( Config::get('app.debug') )
        <!-- build:css(public) css/vendors.min.css -->
        <!-- bower:css -->
        <!-- endbower -->
        <link rel="stylesheet" href="{{ asset('css/app.css') }}">
        <!-- endbuild -->
    @else
        <link rel="stylesheet" href="{{ elixir("css/vendors.min.css") }}">
    @endif
</head>
<body id="app-layout">
    @if ( Config::get('app.debug') )
        <!-- build:js(public) js/vendors.min.js -->
        <!-- bower:js -->
        <!-- endbower -->
        <script src="{{ asset('js/app.js') }}"></script>
        <!-- endbuild -->
    @else
        <script src="{{ elixir('js/vendors.min.js') }}"></script>
    @endif
</body>
</html>
``
**.bowerrc**
```json
{
    "directory": "public/assets/vendor"
}

bower.json:

{
  "name": "laravel",
  "description": "",
  "main": "",
  "authors": [],
  "license": "MIT",
  "moduleType": [],
  "homepage": "",
  "private": true,
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "test",
    "tests"
  ],
  "dependencies": {
    "bootstrap-sass": "^3.3.6",
    "bootstrap-select-sass": "^1.6.3"
  }
}

And the result is

<!DOCTYPE html>
<html lang="en">
<head>
    @if ( Config::get('app.debug') )
        <!-- build:css(public) css/vendors.min.css -->
        <!-- bower:css -->
        <link rel="stylesheet" href="{{ asset('/assets/vendor/bootstrap-select-sass/dist/css/bootstrap-select.css') }}" />
        <!-- endbower -->
        <link rel="stylesheet" href="{{ asset('css/app.css') }}">
        <!-- endbuild -->
    @else
        <link rel="stylesheet" href="{{ elixir("css/vendors.min.css") }}">
    @endif

</head>
<body id="app-layout">
    @if ( Config::get('app.debug') )
        <!-- build:js(public) js/vendors.min.js -->
        <!-- bower:js -->
        <script src="{{ asset('/assets/vendor/jquery/dist/jquery.js') }}"></script>
        <script src="{{ asset('/assets/vendor/bootstrap-sass/assets/javascripts/bootstrap.js') }}"></script>
        <script src="{{ asset('/assets/vendor/bootstrap-select-sass/dist/js/bootstrap-select.js') }}"></script>
        <!-- endbower -->
        <script src="{{ asset('js/app.js') }}"></script>
        <!-- endbuild -->
    @else
        <script src="{{ elixir('js/vendors.min.js') }}"></script>
    @endif
</body>
</html>

Problem of working with laravel-elixir-useref

Wrong path of bower_component be fixed by asset function in #1, but it introduces new bug with laravel-elixir-useref. Consider the example:

    @if (Config::get('app.debug'))
        <!-- build:css(public) css/vendor.css -->
        <!-- bower:css -->
        <link rel="stylesheet" href="{{ asset('bower_components/bootstrap/dist/css/bootstrap.css') }}" />
        <link rel="stylesheet" href="{{ asset('bower_components/font-awesome/css/font-awesome.css') }}" />
        <!-- endbower -->
        <!-- endbuild -->
    @else
        <link rel="stylesheet" href="{{ elixir("css/vendor.css") }}">
    @endif

This would not generate the css/vendor.css because they are not parsable path with asset function.

Any idea?

Laravel Mix

This module is compatibile with Laravel Mix?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.