I was using dynamic component using vue router. Recently i noticed that my vendor file is also causing loading issue. My vendor file size is 4mb+ and in prod is 2mb+ Followed the tutorial So, i wanted to use "Bundle splitting": For that i changed my mix config:
const path = require("path");
mix.webpackConfig({
resolve: {
alias: {
"@": path.resolve(__dirname, "resources/js/")
}
},
output: {
filename: 'js/vue/[name].js',
chunkFilename: 'js/vue/[name].[chunkhash].js'
// chunkFilename: mix.inProduction() ? "js/front/chunks/[name].[chunkhash].js" : "js/front/chunks/[name].js",
//filename: '[name].[chunkhash].js',
// path: path.resolve(__dirname, 'dist'),
},
optimization: {
splitChunks: {
minSize: 10000,
maxSize: 250000,
}
},
----
But when i use splitChunks it makes my vendor file like vendor~cd45250bd7e543e7b708.js And other chunk file also like: 108.4bcdcd35199c4fd01198.js But in my main blade file previously i linked path like:
<script src="{!! asset('js/vue/manifest.js') !!} "></script>
{!! Html::script('js/vue/vendor.js') !!}
{!! Html::script('js/vue/app.js') !!}
Now the vendor.js and app.js not found as they are now on chunkhashed naming. How can i add my vendor chunkhashed file in main blade file ? My package.json:
"devDependencies": {
"axios": "^0.18.0",
"cross-env": "^5.1",
"laravel-mix": "^4.1.4",
"laravel-mix-bundle-analyzer": "^1.0.2",
"resolve-url-loader": "^3.1.0",
"sass": "^1.26.3",
"sass-loader": "^7.3.1",
"vue": "^2.6.11",
"webpack-bundle-analyzer": "^3.5.2"
},
Thanks in advance.