I have php-based API that serves HTML, CSS and JS files to another site for interactive visuals. Bundling was originally done by Mix. I am trying to switch over to Vite.
The issue I am having is that the API was built around the blade.php file, js and css files all having the same names. But when I use Vite to bundle my js and css files to a dist file, it is adding the no. 2 to either my js file or css file.
I found this issue, but there was no resolution.
Note that this is not a Laravel app. I am only using Blade files for templating.
Here is my config:
function getFiles (dir:string):string[] {
// get all 'files' in this directory
// filter directories
return fs.readdirSync(dir).filter(file => {
return fs.statSync(`${dir}/${file}`).isFile();
});
};
export default defineConfig({
root: './app',
build: {
outDir: './../public/dist',
rollupOptions: {
input: [... jsFiles.map(file => `/js/${file}`), ... cssFiles.map(file => `/scss/graphs/${file}`)],
output: {
entryFileNames: 'js/[name].js',
assetFileNames: 'css/[name].css'
},
},
},
plugins:[
usePHP({
entry:['views/layouts/main.blade.php']
})
],
server:{
proxy:{
'/': {
target: 'http://cccdata.test',
secure: false,
changeOrigin: true
}
}
},
css: {
postcss: {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
],
},
}
})
Any idea how I can prevent this from happening?