我不明白为什么vuetify treeshaking在我的应用程序上不起作用,因为我遵循了描述这里的每一个步骤。我漏掉了什么吗?
我用的不是vue CLI,而是webpack 5和vuetify装载机。
我在用:
"vue": "^2.6.14",
"vuetify": "^2.5.10",
"vuetify-loader": "^1.7.3",
"webpack": "^5.61.0",这是我的密码。
plugins/vuetify/index.js
import Vue from 'vue';
import Vuetify from 'vuetify/lib';
const opts = {/*...*/};
Vue.use(Vuetify);
export default new Vuetify(opts);main.js
import Vue from 'vue';
import VueRouter from 'vue-router';
import router from './plugins/router';
import store from './plugins/store';
import vuetify from './plugins/vuetify';
import 'regenerator-runtime/runtime.js';
Vue.use(VueRouter);
new Vue({
el: '#app',
router,
store,
vuetify,
render (createElement) {
return createElement('router-view');
}
});webpack.common.js ( dev和prod的通用配置)
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin');
module.exports = {
plugins: [
new VuetifyLoaderPlugin({
match(originalTag,{ kebabTag, camelTag, path, component}) {
if (kebabTag.startsWith('app-')) {
return [camelTag, `import ${camelTag} from '@/components/global/${kebabTag.substring(4)}.vue'`];
}
}
})
]
}发布于 2022-01-14 14:01:48
我可能会发现webpack的配置对此负有责任。但我不知道它为什么会这么做。知道吗?
在webpack.prod.js中:
optimization: {
splitChunks: { // Extract script from vendors in a separate file
cacheGroups: {
default: false,
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all',
}
}
},
},https://stackoverflow.com/questions/70708569
复制相似问题