All Projects → Diverently → laravel-mix-kirby

Diverently / laravel-mix-kirby

Licence: MIT license
Laravel Mix helper for Kirby

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to laravel-mix-kirby

kirby-minify-html
Enable minify HTML output for Kirby 3
Stars: ✭ 27 (+17.39%)
Mutual labels:  kirby, kirby-cms, kirby-plugin, kirby3
kirby3-many-to-many-field
This plugin allows you to create many-to-many relationships between pages in Kirby and synchronizes them on both sides.
Stars: ✭ 38 (+65.22%)
Mutual labels:  kirby, kirby-cms, kirby-plugin, kirby3
kirby-highlight
Themeable server-side syntax highlighting for Kirby
Stars: ✭ 14 (-39.13%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
kirby-securedpages
Protect pages for authenticated users
Stars: ✭ 28 (+21.74%)
Mutual labels:  kirby-cms, kirby-plugin, kirby3
field-engineer
A Kirby field for complex field structures.
Stars: ✭ 49 (+113.04%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
kirby-blade
Enable Laravel Blade Template Engine for Kirby 3
Stars: ✭ 20 (-13.04%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
search-for-kirby
Kirby 3 plugin for adding a search index (sqlite or Algolia).
Stars: ✭ 42 (+82.61%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
kirby-podcast
A KirbyCMS-Podcast-Plugin
Stars: ✭ 22 (-4.35%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
kirby-membership
Simple Membership plugin for Kirby CMS
Stars: ✭ 27 (+17.39%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
kirby-boiler-field
Boilerplate for Kirby form fields
Stars: ✭ 15 (-34.78%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
retour-for-kirby
Kirby 3 plugin to manage redirects and track 404s right from the Panel
Stars: ✭ 96 (+317.39%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
kirbyup
🆙 Zero-config bundler for Kirby Panel plugins
Stars: ✭ 33 (+43.48%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
vuekit
Kirby 3 + Vue.js kit
Stars: ✭ 16 (-30.43%)
Mutual labels:  kirby, kirby-cms, kirby3
kirby-copy-files
Clone page dashboard widget for Kirby panel
Stars: ✭ 12 (-47.83%)
Mutual labels:  kirby, kirby-plugin
Field Multiselect
Multiselect field for Kirby 2 CMS
Stars: ✭ 84 (+265.22%)
Mutual labels:  kirby, kirby-plugin
Kirby Autogit
⬢ Saves every change made via Kirby Panel to a Git repository
Stars: ✭ 147 (+539.13%)
Mutual labels:  kirby, kirby-plugin
Kirby Uniform
A versatile Kirby plugin to handle web form actions.
Stars: ✭ 214 (+830.43%)
Mutual labels:  kirby, kirby-plugin
Kirby Typography
Typographic enhancements for your Kirby-driven website.
Stars: ✭ 80 (+247.83%)
Mutual labels:  kirby, kirby-plugin
Select A Structure
A select field for Kirby populated by a structure field.
Stars: ✭ 44 (+91.3%)
Mutual labels:  kirby, kirby-plugin
Panel Bar
panelBar for Kirby 2 CMS
Stars: ✭ 70 (+204.35%)
Mutual labels:  kirby, kirby-plugin

Laravel Mix Helper for Kirby

Use the mix helper function to get the correct path to your versioned CSS and JS files generated by Laravel Mix.

Installation

Download

Download and copy this repository to site/plugins/laravel-mix-kirby.

Git submodule

git submodule add https://github.com/Diverently/laravel-mix-kirby.git site/plugins/laravel-mix-kirby

Composer

composer require diverently/laravel-mix-kirby

Laravel Mix

You should also install Laravel Mix, otherwise this plugin is pretty useless ;-) See the installation guide for further information, though it's actually pretty straight forward:

Setup

In your site/config/config.php you can set two options to make this helper work with your specific setup:

diverently.laravel-mix-kirby.manifestPath

This is where the helper function will look for the manifest created by Laravel Mix.

Default: assets/mix-manifest.json

diverently.laravel-mix-kirby.assetsDirectory

This will be prepended to the individual file paths given to the mix() function when creating the final HTML tags.

Default: assets

Options

mix() helper function

The mix() helper function reads the mix-manifest.json file and returns the right HTML tag with the correct path to the requested file. In our example we would call it like so:

<html>
<head>
    <!-- ... -->
    <?php echo mix('/main.css') ?>
    <?php echo mix([
      '/additional.css',
      '@autocss'
    ]) ?>
</head>
<body>
    <!-- ... -->
    <?php echo mix('/main.js') ?>
    <?php echo mix([
      '/additional.js',
      '@autojs'
    ]) ?>
</body>
</html>

And that's it, actually.

Development

  1. If you haven't already, create a package.json inside your project root: npm init -y
  2. Install Laravel Mix: npm install laravel-mix --save-dev
  3. Copy the webpack.mix.js file into your root: cp node_modules/laravel-mix/setup/webpack.mix.js ./

After that you can start using Laravel Mix in your project.

webpack.mix.js

See the official documentation for more information.

let mix = require("laravel-mix")
mix.setPublicPath("assets")
mix.browserSync("my-website.dev")
if (mix.inProduction()) {
  mix.version()
}
mix
  .sourceMaps()
  .js("src/js/main.js", "assets")
  .sass("src/css/main.scss", "assets")

NPM scripts

Add the following NPM scripts to your package.json:

"scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "npm run development -- --watch",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
}

License

MIT

Credits

Robert Cordes

Diverently

The idea behind this originally came from the mix Blade helper created for the Laravel framework. This is merely a "translation" for the Kirby CMS, only that it also generates the correct HTML tag depending on what file type you request.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].