npm

Does your artifact manager get in the way? Join us on Oct. 8 at 10am PT, to discuss how npm can help.Sign up »

laravel-bundler

0.11.0 • Public • Published

Laravel Bundler

downloads npm-version github-tag license build-status

Modern asset building tool for Laravel framework with better defaults.

Installation

⚠️ This package does not work with laravel-mix; you should remove laravel-mix before using this one

# npm 
npm install laravel-bundler 
 
# yarn 
yarn add laravel-bundler

Usage

Create a webpack.config.js file on your project root and remove webpack.mix.js if exists.

module.exports = require('laravel-bundler')({
  entry: {
    app: './resources/js/app.js',
  },
  // Other webpack configs
});

Update your package.json

"scripts"{
    "dev": "cross-env NODE_ENV=development webpack --progress --mode development",
    "watch": "npm run dev -- --watch",
    "prod": "cross-env NODE_ENV=production webpack --progress --mode production",
    "hot": "cross-env NODE_ENV=development webpack-dev-server --progress --hot"
},
"browserslist"[
    "> 1%",
    "not IE 11"
]  

Update your blade template

<!-- header -->
<link href="{{ mix('css/app.css') }}" rel="stylesheet">
 
<!-- footer -->
<script src="{{ mix('js/manifest.js') }}"></script>
<script src="{{ mix('js/vendor.js') }}"></script>
<script src="{{ mix('js/app.js') }}"></script>

Update your .gitignore

/public/hot
/public/js
/public/css
/public/fonts
/public/images
/public/mix-manifest.json

Baked Features

  • Webpack 4, Babel 7 with @babel/preset-env
  • Vue.js support - Recipe
  • CSS|SASS|SCSS with CSS modules support
  • PostCSS loader with autoprefixer and cssnano
  • Font and image files handling
  • HMR support, even for CSS 🔥
  • Extract all css to a separate file based on entry name
  • Extract all vendor js to a separate file
  • Clean output directories before build
  • mix-manifest.json compatible with Laravel's mix() helper
  • Load environment variables from .env file that are prefixed with MIX_
  • Intelligent SourceMap

Documentation

Not in the plan

These features are not in the plan but can be enabled on demand

License

MIT License

install

npm i laravel-bundler

Downloadsweekly downloads

4

version

0.11.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability