laravel-mix-jigsaw
v2.1.1
Published
Laravel Mix plugin for Jigsaw
Downloads
2,229
Maintainers
Readme
Jigsaw plugin for Laravel Mix
laravel-mix-jigsaw
is a Laravel Mix plugin for the Jigsaw static site generator. It watches your Jigsaw site's files and triggers a new Mix build when it detects changes.
const mix = require('laravel-mix');
require('laravel-mix-jigsaw');
mix.jigsaw()
.js('source/_assets/js/main.js', 'js')
.css('source/_assets/css/main.css', 'css')
.version();
Installation
npm install -D laravel-mix-jigsaw
Usage
Require the module in your webpack.mix.js
file.
const mix = require('laravel-mix');
require('laravel-mix-jigsaw');
Enable the build tasks by calling .jigsaw()
anywhere in your Mix build chain.
mix.js('source/_assets/js/main.js', 'js')
.css('source/_assets/css/main.css', 'css')
.jigsaw();
By default this plugin watches common Jigsaw file paths and triggers a new build when it detects changes. To add watched paths or override the watcher configuration, pass a config object to .jigsaw()
:
// Add additional file paths to watch
mix.jigsaw({
watch: ['config.*.php'],
});
// Override the default config
mix.jigsaw({
watch: {
files: ['source/posts/*.blade.php'],
notDirs: ['source/_assets/', 'source/assets/', 'source/ignore/'],
},
});
If you use Laravel Mix's built-in BrowserSync integration, you may need to configure it to watch Jigsaw's paths:
mix.jigsaw()
.browserSync({
server: 'build_local',
files: ['build_*/**'],
});
Caveats
- The plugin cannot detect the creation of new files immediately inside the
source/
directory of your site. If you create a new file likesource/home.blade.php
, you'll need to stop and restart Mix. - With v1 of the plugin it was possible to add additional Webpack plugins/tasks that would run after the Jigsaw build but before Mix finished compiling assets. This created compatibility issues between this plugin and Mix itself, and was removed in v2. If you need to perform additional processing after your Jigsaw site is built, like minifying its HTML, you can do so using a Jigsaw event listener.
Credits
Huge thanks to Brandon Nifong for creating the initial version of this plugin!
License
Laravel Mix Jigsaw is provided under the MIT License.