after run npm run build
and open localhost:8000 auto redirect me to localhost:8000/build
vite.config.js :
<code>import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import path from 'path';
export default defineConfig({
base: '/',
build: {
rollupOptions: {
output: {
manualChunks: {
vendor: ['vue', 'axios', 'smoothscroll-polyfill', 'vue3-star-ratings', 'vue-sweetalert2'], // add other common libraries you want to separate
},
},
},
},
plugins: [
laravel({
input: [
'resources/js/main.js',
],
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'resources/js'),
},
},
});
</code>
<code>import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import path from 'path';
export default defineConfig({
base: '/',
build: {
rollupOptions: {
output: {
manualChunks: {
vendor: ['vue', 'axios', 'smoothscroll-polyfill', 'vue3-star-ratings', 'vue-sweetalert2'], // add other common libraries you want to separate
},
},
},
},
plugins: [
laravel({
input: [
'resources/js/main.js',
],
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'resources/js'),
},
},
});
</code>
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import path from 'path';
export default defineConfig({
base: '/',
build: {
rollupOptions: {
output: {
manualChunks: {
vendor: ['vue', 'axios', 'smoothscroll-polyfill', 'vue3-star-ratings', 'vue-sweetalert2'], // add other common libraries you want to separate
},
},
},
},
plugins: [
laravel({
input: [
'resources/js/main.js',
],
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'resources/js'),
},
},
});
/public/.htaccess :
<code><IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</code>
<code><IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</code>
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
i add base: ‘/’ to vite.config.js and run
<code>php artisan cache:clear
php artisan config:clear
php artisan view:clear
php artisan route:clear
</code>
<code>php artisan cache:clear
php artisan config:clear
php artisan view:clear
php artisan route:clear
</code>
php artisan cache:clear
php artisan config:clear
php artisan view:clear
php artisan route:clear
and run after
<code>npm run build
</code>
<code>npm run build
</code>
npm run build
website work normally localhost:8000/build for the first time , but when i reload the page gets error :
Not Found
The requested resource /build/ was not found on this server.
New contributor
hani_sulaiman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.