npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

laravel-bundler

v2.9.1

Published

Modern and fast asset building tool for Laravel framework with better defaults.

Downloads

359

Readme

Asset Bundler for Laravel

downloads npm-version github-tag license install size tests

Modern and fast asset building tool for Laravel framework with better defaults.

Installation

:bulb: This package does not work with laravel-mix; you must remove laravel-mix before using this one

npm install --save-dev laravel-bundler@^2

Usage

Create a resources/js/app.js file like

// Example: Vue.js v2 with bootstrap
import Vue from 'vue';
// You can import styles like this
import 'bootstrap/dist/css/bootstrap.css'

import RegularComponent from './Regular.vue'

const LazyLoadedComponent = () => import('./HeavyComponent.vue');

new Vue({
    el: "#app",
    components: {
        RegularComponent,
        LazyLoadedComponent,
    }
});

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

import webpack from 'webpack'
import {createConfig} from 'laravel-bundler';
import vue2Recipe from 'laravel-bundler/src/recipes/vue-2.js';

export default createConfig({
        entry: {
            app: './resources/js/app.js',
        },
        plugins: [
            //
        ],
        // Other webpack configs may go here
    },
    // Include vue v2 recipe
    // Dont forget to install required packages by this recipe
    vue2Recipe
);

Update your package.json file

{
    "type": "module",
    "scripts": {
        "dev": "webpack --define-process-env-node-env=development --progress",
        "watch": "webpack watch --define-process-env-node-env=development --progress",
        "hot": "webpack serve --define-process-env-node-env=development --progress --hot",
        "hot:https": "npm run hot -- --https",
        "prod": "webpack --define-process-env-node-env=production --progress"
    },
    "browserslist": [
        "> 2%",
        "not dead"
    ],
    "babel": {
        "presets": [
            [
                "@babel/preset-env",
                {
                    "bugfixes": true
                }
            ]
        ],
        "plugins": []
    }
}

Update your blade template

<!-- header -->
<link href="{{ mix('css/app.css', 'dist') }}" rel="stylesheet">

<!-- footer -->
<script src="{{ mix('js/manifest.js', 'dist') }}"></script>
<script src="{{ mix('js/vendor.js', 'dist') }}"></script>
<script src="{{ mix('js/app.js', 'dist') }}"></script>

Update your .gitignore file

/public/dist

Features

  • Webpack 5 and Babel 7 with @babel/preset-env
  • Use esbuild to minify CSS and JS :rocket:
  • Vue.js v2 support - Recipe
  • Vue.js v3 support - Recipe
  • CSS and SASS|SCSS support
  • PostCSS loader pre-configured with autoprefixer
  • Font and image files handling
  • Full HMR support for Vue, even for CSS :fire:
  • Extract all css to a separate file (based on entry)
  • Accepts css/scss file as entry
  • Extract all vendor js to a separate file
  • Dynamic import (code splitting) support :mage_man:
  • Clean the output directory before emitting the assets
  • Generates a mix-manifest.json file which is compatible with Laravel's mix() helper
  • Load environment variables from .env file that are prefixed with MIX_ :wink:
  • Intelligent SourceMap based on mode
  • Can auto-reload web-browser when blade templates gets changed :wink:

Documentation

Not in the plan

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

License

MIT License