Js Partial

Laravel Mix extension for JS Partials.
latest v1.0.1 - released
abhisheksatre
4 downloads last week
MIT license
3 versions
partials

Laravel Mix JS Partials

Software License Latest Version on NPM

This package adds a jsPartial option to Laravel Mix, which copies JS code into a partial file.

Usage

First, install the extension.

npm install laravel-mix-js-partial --save-dev

Then, require it within your webpack.mix.js file:

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

require('laravel-mix-js-partial');

mix.jsPartial('js/gallery.js', 'partials/gallery-js.php');


Note: If you are using setPublicPath option in your mix file then declare setPublicPath option before jsPartial option.

mix.setPublicPath('dist').jsPartial('js/gallery.js', 'partials/gallery-js.php');

Examples:

// 1. A single src and output path.
mix.jsPartial('src/gallery.js', 'partials/gallery-js.php');

// 2. For additional src files that should be bundled together:
mix.jsPartial([
    'src/gallery.js',
    'src/nac.js'
], 'partials/gallery-js.php');

// 3. For multiple partials:
mix.jsPartial('src/gallery.js', 'partials/gallery-js.php')
   .jsPartial('src/nav.js', 'partials/nav-js.php');