admin管理员组文章数量:1122832
I'm using Laravel 6 (Mix) and Vue.js 2 for my project. When I run the yarn prod command on the server, it generates a large production file, which significantly increases the load time of the website.
I've also added extract in my webpack.mix.js configuration to separate vendor files, but the file size issue persists.
The sizes of the generated files are:
/v2/js/vendor.js?id=4b6042a699ca621c856y - 1.9 MiB (27%)
/v2/js/app.js?id=0892f4497fbbbad7bbg4 - 652.2 KiB (9%)
Additionally, analysis tools show that nearly 50% of the content in these files is unused.
Here's my webpack.mix.js file:
require('laravel-mix-svg-vue');
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin');
mix.js("resources/v2/js/app.js", "public/v2/js").vue().svgVue({
svgPath: 'resources/v2/assets/svg',
extract: false,
svgoSettings: [{ removeTitle: true }, { removeViewBox: false }, { removeDimensions: true }]
})
.extract([
'vue', 'vuex', 'vee-validate', 'lodash',
'vuetify', 'feather-icons', 'dayjs',
'tailwindcss', 'masonry-layout',
'swiper', 'mapbox-gl', 'vue-awesome-swiper', '@mapbox/mapbox-gl-draw'
])
.copyDirectory("resources/v2/assets/images", "public/v2/assets/images")
.copyDirectory("resources/v2/assets/svg", "public/v2/assets/svg")
.copyDirectory("resources/v2/assets/fonts", "public/v2/assets/fonts")
.postCss("resources/v2/css/materialdesignicons.min.css", "public/v2/css")
.postCss("resources/v2/css/app.css", "public/v2/css", [require('tailwindcss')])
.webpackConfig({
plugins: [
new VuetifyLoaderPlugin()
]
});
mix.webpackConfig({
output: {
chunkFilename: '[name].js?id=[contenthash]',
},
});
if (mix.inProduction()) {
mix.version();
const ASSET_URL = process.env.ASSET_URL + "/";
mix.webpackConfig(webpack => {
return {
plugins: [new webpack.DefinePlugin({
"process.env.ASSET_PATH": JSON.stringify(ASSET_URL)
})], output: {
publicPath: ASSET_URL
}
};
});
}
How can I reduce the size of the production build file and optimize the loading time of my website? Any suggestions or improvements for my webpack.mix.js configuration are greatly appreciated!
本文标签: javascriptLarge Production Build File Size in Laravel 6 (Mix) with Vuejs 2Stack Overflow
版权声明:本文标题:javascript - Large Production Build File Size in Laravel 6 (Mix) with Vue.js 2 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736303562a1931930.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论