fabioantunes / laravel-elixir-wiredep Goto Github PK
View Code? Open in Web Editor NEWThis is a simple wrapper around Laravel Elixir for Wiredep.
License: MIT License
This is a simple wrapper around Laravel Elixir for Wiredep.
License: MIT License
It would be nice to also update sass and less files if blocks exist in them for a complete solution out of the box.
Should the ignorePath on the default configuration be something more like /(\..\/)*/
I don't see any instance where the public would match and have had to put ignorePath in explicitly in the past to accommodate.
This module is compatibile with Laravel Mix?
Your script on production gulp --production
should concat and minify the scripts and styles.
Nice plugin, but still useless in real world.
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>
Laravel Elixir 3 removed 'laravel-elixir/ingredients/commands/Utilities', but laravel-elixir-wiredep depends on it.
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?
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.