v4
Vite Configuration

Vite configuration

Installing Craftable PRO copies a Vite config file, craftable-pro.vite.config.js, to your project. You run it with npm run craftable-pro:dev. This keeps the Craftable PRO build separate from your project's own build.

Craftable PRO v4 is built with Vite 8 and Tailwind CSS 4 (through the @tailwindcss/vite plugin). Vite 8 requires Node.js 20.19+ or 22.12 and newer (Node 24 and 26 work too).

Scripts

Craftable PRO comes with two NPM scripts in package.json to build assets. Those are:

  • npm run craftable-pro:dev -> runs Vite in development mode
  • npm run craftable-pro:build -> runs Vite in production mode

Default config

This is the config the installer publishes:

craftable-pro.vite.config.js
import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import tailwindcss from "@tailwindcss/vite";
 
export default defineConfig({
  plugins: [
    laravel({
      input: [
        "resources/js/craftable-pro/index.ts",
        "resources/css/craftable-pro.css",
      ],
      refresh: true,
    }),
    tailwindcss(),
    vue({
      template: {
        transformAssetUrls: {
          base: null,
          includeAbsolute: false,
        },
      },
    }),
  ],
  // Keep the admin build isolated from the app's own postcss.config.js
  // (e.g. a Tailwind 3 setup with tailwindcss/autoprefixer plugins).
  css: {
    postcss: {
      plugins: [],
    },
  },
  resolve: {
    alias: {
      "@": resolve(import.meta.dirname, "./resources/js"),
      "craftable-pro": resolve(
        import.meta.dirname,
        "./vendor/brackets/craftable-pro/resources/js"
      ),
      ziggy: resolve(import.meta.dirname, "./vendor/tightenco/ziggy"),
    },
  },
});
💡

Keep the empty css.postcss.plugins list. Without it, Vite loads your app's own postcss.config.js, and a Tailwind 3 one (with tailwindcss and autoprefixer plugins) breaks the admin build.

Aliases

Craftable PRO needs three Vite aliases to work properly. These aliases are defined in the craftable-pro.vite.config.js file. Below is their explanation for better orientation:

  • @ - pointing to resources folder in your project, where are located some of the components for better customizability. This alias is used by some of the Craftable PRO components, so please don't change it since it might break your layout.
  • craftable-pro - used to load all Craftable PRO components
  • ziggy - used to load helper functions from Ziggy to used named routes in your project

Stylesheet

There is no Tailwind config file. The admin's theme lives in the package's CSS, and your project keeps only a small entry stylesheet:

resources/css/craftable-pro.css
@import "tailwindcss" source(none);
@import "craftable-pro/../css/craftable-pro.css";
 
@plugin "@tailwindcss/typography";
@plugin "@tailwindcss/forms";
 
@source "../views/craftable-pro.blade.php";
@source "../js/craftable-pro";
@source "../../vendor/brackets/craftable-pro/resources/js";

The @source lines are required. Tailwind 4 skips git-ignored folders such as vendor/ when it looks for class names, so without them the admin's styles are missing. source(none) stops Tailwind from scanning the rest of your app, so your own frontend classes don't end up in the admin's CSS.

To change the theme, see Customization.

Combining Vite configs

If you use Vite in your project already for the frontend side of your application, you can combine your Vite config with the one from Craftable PRO. This is useful if you don't want to have two separate npm scripts for running Vite.

New Laravel 12 and 13 apps already use Tailwind CSS 4 with the @tailwindcss/vite plugin, so both stylesheets are built by the same plugin. Each one keeps its own @source list, so the two builds don't mix.

To combine them, please follow steps below:

Add input files

Add the Craftable PRO input files into your vite.config.js file:

vite.config.js
import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import tailwindcss from "@tailwindcss/vite";
 
export default defineConfig({
  plugins: [
    laravel({
      input: [
        "resources/css/app.css",
        "resources/js/app.js",
        "resources/js/craftable-pro/index.ts",
        "resources/css/craftable-pro.css",
      ],
      refresh: true,
    }),
    tailwindcss(),
  ],
});

Add Vue Vite plugin

You may not need to add this plugin if you already have it in your vite.config.js file.

vite.config.js
import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import vue from "@vitejs/plugin-vue";
import tailwindcss from "@tailwindcss/vite";
 
export default defineConfig({
  plugins: [
    laravel({
      input: [
        "resources/css/app.css",
        "resources/js/app.js",
        "resources/js/craftable-pro/index.ts",
        "resources/css/craftable-pro.css",
      ],
      refresh: true,
    }),
    tailwindcss(),
    vue({
      template: {
        transformAssetUrls: {
          base: null,
          includeAbsolute: false,
        },
      },
    }),
  ],
});

Add aliases

vite.config.js
import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import tailwindcss from "@tailwindcss/vite";
 
export default defineConfig({
  plugins: [
    laravel({
      input: [
        "resources/css/app.css",
        "resources/js/app.js",
        "resources/js/craftable-pro/index.ts",
        "resources/css/craftable-pro.css",
      ],
      refresh: true,
    }),
    tailwindcss(),
    vue({
      template: {
        transformAssetUrls: {
          base: null,
          includeAbsolute: false,
        },
      },
    }),
  ],
  resolve: {
    alias: {
      "@": resolve(import.meta.dirname, "./resources/js"),
      "craftable-pro": resolve(
        import.meta.dirname,
        "./vendor/brackets/craftable-pro/resources/js"
      ),
      ziggy: resolve(import.meta.dirname, "./vendor/tightenco/ziggy"),
    },
  },
});
⚠️

Your project still on Tailwind CSS 3 with a postcss.config.js? Then don't combine the configs. Keep the separate craftable-pro.vite.config.js, which ignores your PostCSS config, or upgrade your project to Tailwind CSS 4 first.

Edit package.json

Remove craftable-pro:dev and craftable-pro:build scripts from your package.json file, since they are not needed anymore.

package.json
{
    ...
    "scripts": {
        "dev": "vite",
        "build": "vite build",
        "craftable-pro:dev": "vite --config craftable-pro.vite.config.js",
        "craftable-pro:build": "vite build --config craftable-pro.vite.config.js"
    },
    ...
}

Remove config

Just delete the craftable-pro.vite.config.js file from your project once you completed the steps above.

Run Vite

Run Vite with npm run dev to verify if everything works as expected. From now on, Vite builds both your frontend files and the Craftable PRO ones with a single command.