JSPM

laravel-mix-js-partial

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q38827F
  • License MIT

Laravel Mix extension for JS Partials

Package Exports

  • laravel-mix-js-partial
  • laravel-mix-js-partial/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (laravel-mix-js-partial) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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');