File tree Expand file tree Collapse file tree 3 files changed +68
-1
lines changed Expand file tree Collapse file tree 3 files changed +68
-1
lines changed Original file line number Diff line number Diff line change 1
1
import Vue from 'vue'
2
2
import Vuetify from '<%= options.treeShake ? ' vuetify / lib ' : ' vuetify ' %>'
3
+ < %
4
+ const libImports = [
5
+ { key : 'components' , location : 'vuetify/lib' } ,
6
+ { key : 'transitions' , location : 'vuetify/lib' } ,
7
+ { key : 'directives' , location : 'vuetify/lib/directives' }
8
+ ]
9
+ if ( options . treeShake ) {
10
+ for ( const lib of libImports ) {
11
+ if ( options . treeShake [ lib . key ] && options . treeShake [ lib . key ] . length > 0 ) {
12
+ % >
13
+ import { < %= options . treeShake [ lib . key ] . join ( ', ' ) % > } from '<%= lib.location %>'
14
+ < %
15
+ }
16
+ }
17
+ }
18
+ % >
19
+
3
20
import options from './options'
4
21
5
- Vue . use ( Vuetify )
22
+ Vue . use ( Vuetify , {
23
+ < %
24
+ if ( options . treeShake ) {
25
+ for ( const lib of libImports ) {
26
+ if ( options . treeShake && options . treeShake [ lib . key ] && options . treeShake [ lib . key ] . length > 0 ) {
27
+ % >
28
+ < %= lib . key % > : { < %= options . treeShake [ lib . key ] . join ( ', ' ) % > }
29
+ < %
30
+ }
31
+ }
32
+ }
33
+ % >
34
+ } )
6
35
7
36
export default ( ctx ) => {
8
37
const vuetifyOptions = typeof options === 'function' ? options ( ctx ) : options
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <v-container >
3
+ <v-layout >
4
+ <v-flex >
5
+ <!-- eslint-disable-next-line vue/require-component-is -->
6
+ <component is =" v-chip" >
7
+ Default
8
+ </component >
9
+ </v-flex >
10
+ </v-layout >
11
+ </v-container >
12
+ </template >
Original file line number Diff line number Diff line change @@ -100,3 +100,29 @@ describe.skip('enable treeShake', () => {
100
100
expect ( html ) . toContain ( 'v-navigation-drawer--fixed' )
101
101
} )
102
102
} )
103
+
104
+ describe . skip ( 'manually import' , ( ) => {
105
+ let nuxt
106
+
107
+ beforeAll ( async ( ) => {
108
+ nuxt = new Nuxt ( {
109
+ ...config ,
110
+ vuetify : {
111
+ treeShake : {
112
+ components : [ 'VChip' ]
113
+ }
114
+ }
115
+ } )
116
+ await nuxt . ready ( )
117
+ await new Builder ( nuxt ) . build ( )
118
+ } )
119
+
120
+ afterAll ( async ( ) => {
121
+ await nuxt . close ( )
122
+ } )
123
+
124
+ test ( 'render' , async ( ) => {
125
+ const { html } = await nuxt . renderRoute ( '/manual-import' )
126
+ expect ( html ) . toContain ( 'v-chip__content' )
127
+ } )
128
+ } )
You can’t perform that action at this time.
0 commit comments