Skip to main content
Version: 5.x

Front-End Assets

Introduction​

Bow comes preconfigured with a modern Frontend environment based on Vite, including:

This setup provides instant reloading (HMR) and ultra-fast compilation.

Installation​

npm install

Commands​

CommandDescription
npm run devStarts the Vite development server with HMR
npm run buildCompiles and optimizes for production

Development​

npm run dev

Starts the Vite server with hot reloading. Changes are reflected instantly without reloading the page.

Production​

npm run build

Compiles and minifies the assets into the public/ folder.

File Structure​

assets/
β”œβ”€β”€ js/
β”‚ β”œβ”€β”€ app.js # Main entry point
β”‚ β”œβ”€β”€ Example.jsx # React component
β”‚ └── Example.vue # Vue component
β”œβ”€β”€ sass/
β”‚ β”œβ”€β”€ app.scss # Main styles
β”‚ └── variables.scss # SCSS variables
└── css/
└── app.css # CSS/Tailwind

Vite Configuration​

vite.config.js
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import react from '@vitejs/plugin-react';
import path from 'path';
import tailwindcss from '@tailwindcss/vite';

export default defineConfig({
plugins: [
vue(),
react(),
tailwindcss(),
],
root: path.resolve(__dirname, 'assets'),
build: {
outDir: path.resolve(__dirname, 'public'),
emptyOutDir: true,
rollupOptions: {
input: {
app: path.resolve(__dirname, 'assets/js/app.js'),
},
output: {
entryFileNames: 'js/[name].js',
assetFileNames: (assetInfo) => {
if (/\.(css|scss)$/.test(assetInfo.name)) {
return 'css/[name]-[hash][extname]';
}
if (/\.(png|jpe?g|gif|svg|webp)$/.test(assetInfo.name)) {
return 'img/[name]-[hash][extname]';
}
return '[ext]/[name]-[hash][extname]';
},
},
},
},
});

Tailwind CSS​

Configuration​

tailwind.config.js
import defaultTheme from "tailwindcss/defaultTheme";

export default {
content: [
"./templates/**/*.{blade,tintin}.php",
"./templates/**/*.twig",
"./templates/**/*.{js,jsx,ts,tsx,vue}",
"./assets/js/**/*.{js,jsx,ts,tsx,vue}",
],
theme: {
extend: {
fontFamily: {
sans: ["Figtree", ...defaultTheme.fontFamily.sans],
},
},
},
plugins: [],
};

Usage​

assets/css/app.css
@tailwind base;
@tailwind components;
@tailwind utilities;

/* Custom styles */
.btn-primary {
@apply bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600;
}

React Components​

assets/js/Example.jsx
import React, { useState } from 'react';

export default function Example() {
const [count, setCount] = useState(0);

return (
<div className="p-4">
<h1 className="text-2xl font-bold">