Hi Log1x
Thankyou for your help!
I’m able to setup react.js now. But I do have another query here is, On running npm run dev
its starting the local server with the info mentioned below:
VITE v6.2.5 ready in 604 ms
➜ Local: http://localhost:5173/wp-content/themes/sage/public/build/
➜ Network: use --host to expose
➜ press h + enter to show help
LARAVEL plugin v1.2.0
➜ APP_URL: undefined
However, I have to access the local website at http://sage.local instead localhost:3000 or localhost:5173. That’s fine but when the dev server is running only then I can see the development at http://sage.local on closing the dev server, it’s throwing error:
I tried by making a build by running npm run build
, its still remains the same.
There must be something wrong with the react configuration but I’m not able to find it out. Can you please help me to figure this out?
Attaching my vite.config.js file for your reference:
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite';
import react from '@vitejs/plugin-react';
import laravel from 'laravel-vite-plugin'
import { wordpressPlugin, wordpressThemeJson } from '@roots/vite-plugin';
export default defineConfig({
base: '/wp-content/themes/sage/public/build/',
plugins: [
tailwindcss(),
react({ include: /\.(mdx|js|jsx|ts|tsx)$/ }),
laravel({
input: [
'resources/css/app.css',
'resources/js/app.jsx',
'resources/css/editor.css',
'resources/js/editor.js',
],
refresh: true,
}),
wordpressPlugin(),
// Generate the theme.json file in the public/build/assets directory
// based on the Tailwind config and the theme.json file from base theme folder
wordpressThemeJson({
disableTailwindColors: false,
disableTailwindFonts: false,
disableTailwindFontSizes: false,
}),
],
build: {
manifest: true,
outDir: 'dist',
rollupOptions: {
input: './resources/js/app.jsx'
}
},
resolve: {
alias: {
'@scripts': '/resources/js',
'@styles': '/resources/css',
'@fonts': '/resources/fonts',
'@images': '/resources/images',
},
extensions: ['.js', '.jsx'],
},
})
Thanks