ages96 / Tesvan

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Total Downloads Latest Stable Version License

About Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:

Laravel is accessible, powerful, and provides tools required for large, robust applications.

Learning Laravel

Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.

If you don't feel like reading, Laracasts can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.

Laravel Sponsors

We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel Patreon page.

Premium Partners

Contributing

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via taylor@laravel.com. All security vulnerabilities will be promptly addressed.

License

The Laravel framework is open-sourced software licensed under the MIT license.

Optimization

Though Laravel Mix is optimized for Laravel usage, it may be used for any type of application. Begin by installing Laravel Mix through NPM or Yarn, and then copying the example Mix file to your project root.

mkdir my-app && cd my-app
npm init -y
npm install laravel-mix --save-dev
cp node_modules/laravel-mix/setup/webpack.mix.js ./

You should now have the following directory structure:

node_modules/
package.json
webpack.mix.js

The webpack.mix.js file is your configuration layer on top of webpack. Most of your time will be spent here.

Head over to your webpack.mix.js file:

const mix = require('laravel-mix');

mix.js('src/app.js', 'dist')
   .sass('src/app.scss', 'dist')
   .setPublicPath('dist');

Take note of the source paths. You're free to amend the paths to match your preferred structure, but if you're happy with our defaults simply run the following command to create the files and directories:

mkdir src && touch src/app.{js,scss}

You're all set now. Compile everything down by running:

node_modules/.bin/webpack --config=node_modules/laravel-mix/setup/webpack.config.js

You should now see:

dist/app.css
dist/app.js
dist/mix-manifest.json (Your asset dump file, which we'll discuss later.)

Concatenation and Minification

mix.combine(['src', 'files'], 'destination');
mix.babel(['src', 'files'], destination);
mix.minify('src');
mix.minify(['src']);

If used properly, Laravel Mix and webpack should take care of all the necessary module bundling and minification for you. However, you may have some legacy code or vendor libraries that need to be concatenated and minified. Not a problem.

Combine Files

Consider the following snippet:

mix.combine(['one.js', 'two.js'], 'merged.js');

This will naturally merge one.js and two.js into a single file, called merged.js. As always, during development, that merged file will remain uncompressed. However, for production (export NODE_ENV=production), this command will additionally minify merged.js.

Combine Files With Babel Compilation

If you need to concatenate JavaScript files that have been written in ES2015, you may update your mix.combine() call to mix.babel(). The method signature is identical. The only difference is that, after the files have been concatenated, Laravel Mix will perform Babel compilation on the result to transform the code to vanilla JavaScript that all browsers can understand.

mix.babel(['one.js', 'two.js'], 'merged.js');

Minify Files

Similarly, you may also minify one or more files with the mix.minify() command.

mix.minify('path/to/file.js');
mix.minify(['this/one.js', 'and/this/one.js']);

There are a few things worth noting here:

  1. This method will create a companion *.min.ext file. So minifying app.js will generate app.min.js.
  2. Once again, the minification will only take place during a production build. (export NODE_ENV=production).
  3. There is no need to call mix.combine(['one.js', 'two.js'], 'merged.js').minify('merged.js');Just stick with the single mix.combine() call. It'll take care of both.

About


Languages

Language:Blade 86.6%Language:PHP 7.7%Language:HTML 4.7%Language:Less 0.9%Language:Shell 0.0%Language:Vue 0.0%