@@ -3,67 +3,55 @@ const fs = require('fs'),
3
3
extendBabel = require ( '../lib/extendBabel' )
4
4
5
5
const message = `
6
- Documentation can be found at: https://quasar-framework.org
6
+ Documentation can be found at: https://v1. quasar-framework.org
7
7
8
8
Quasar is relying on donations to evolve. We'd be very grateful if you can
9
9
take a look at: https://www.patreon.com/quasarframework
10
10
Any amount is very welcomed.
11
- If invoices are required, please first contact razvan[email protected]
11
+ If invoices are required, please first contact razvan@quasar-framework.org
12
12
13
13
Please give us a star on Github if you appreciate our work:
14
14
https://github.com/quasarframework/quasar
15
15
16
16
Enjoy! - Quasar Team
17
17
`
18
18
19
- module . exports = ( api , opts , rootOpts ) => {
20
- const components = opts . quasar . v1
21
- ? [
22
- 'QLayout' ,
23
- 'QHeader' ,
24
- 'QDrawer' ,
25
- 'QPageContainer' ,
26
- 'QPage' ,
27
- 'QToolbar' ,
28
- 'QToolbarTitle' ,
29
- 'QBtn' ,
30
- 'QIcon' ,
31
- 'QList' ,
32
- 'QItem' ,
33
- 'QItemSection' ,
34
- 'QItemLabel'
35
- ]
36
- : [
37
- 'QBtn' ,
38
- 'QLayout' ,
39
- 'QLayoutHeader' ,
40
- 'QLayoutDrawer' ,
41
- 'QPage' ,
42
- 'QPageContainer' ,
43
- 'QToolbar' ,
44
- 'QToolbarTitle' ,
45
- 'QList' ,
46
- 'QListHeader' ,
47
- 'QItemSeparator' ,
48
- 'QItem' ,
49
- 'QItemSide' ,
50
- 'QItemMain'
51
- ] ,
52
- directives = [ ] ,
53
- plugins = [ ]
54
-
55
- const tsPath = api . resolve ( './src/main.ts' ) ,
19
+ const iconMap = {
20
+ ionicons : 'ionicons-v4' ,
21
+ fontawesome : 'fontawesome-v5' ,
22
+ mdi : 'mdi-v3'
23
+ }
24
+
25
+ module . exports = ( api , opts ) => {
26
+ const components = [
27
+ 'QLayout' ,
28
+ 'QHeader' ,
29
+ 'QDrawer' ,
30
+ 'QPageContainer' ,
31
+ 'QPage' ,
32
+ 'QToolbar' ,
33
+ 'QToolbarTitle' ,
34
+ 'QBtn' ,
35
+ 'QIcon' ,
36
+ 'QList' ,
37
+ 'QItem' ,
38
+ 'QItemSection' ,
39
+ 'QItemLabel'
40
+ ]
41
+
42
+ const directives = [ ]
43
+ const plugins = [ ]
44
+
45
+ const
46
+ tsPath = api . resolve ( './src/main.ts' ) ,
56
47
jsPath = api . resolve ( './src/main.js' ) ,
57
48
hasTS = fs . existsSync ( tsPath )
58
- const dependencies = opts . quasar . v1
59
- ? {
60
- quasar : '^1.0.0-beta.1' ,
61
- '@quasar/extras' : '^1.0.0'
62
- }
63
- : {
64
- 'quasar-framework' : '^0.17.0' ,
65
- 'quasar-extras' : '^2.0.4'
66
- }
49
+
50
+ const dependencies = {
51
+ quasar : '^1.0.0-beta.1' ,
52
+ '@quasar/extras' : '^1.0.0'
53
+ }
54
+
67
55
const deps = {
68
56
dependencies,
69
57
devDependencies : {
@@ -81,40 +69,35 @@ module.exports = (api, opts, rootOpts) => {
81
69
82
70
// modify plugin options
83
71
extendPluginOptions ( api , ( pluginOptions , transpileDependencies ) => {
84
- pluginOptions . quasar = {
85
- theme : opts . quasar . theme
86
- }
72
+ pluginOptions . quasar = pluginOptions . quasar || { }
73
+
87
74
if ( opts . quasar . rtlSupport ) {
88
- pluginOptions . quasar . rtlSupport = true
89
- }
90
- if ( opts . quasar . all ) {
91
- pluginOptions . quasar . importAll = true
75
+ pluginOptions . quasar . rtlSupport = opts . quasar . rtlSupport
92
76
}
93
- if ( opts . quasar . v1 ) {
94
- pluginOptions . quasar . v1 = true
77
+
78
+ if ( opts . quasar . treeShake ) {
79
+ pluginOptions . quasar . treeShake = opts . quasar . treeShake
95
80
}
96
- const transpileRegex = opts . quasar . v1
97
- ? / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] q u a s a r [ \\ / ] /
98
- : / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] q u a s a r - f r a m e w o r k [ \\ / ] /
99
- transpileDependencies . push ( transpileRegex )
81
+
82
+ transpileDependencies . push ( / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] q u a s a r [ \\ / ] / )
100
83
101
84
return { pluginOptions, transpileDependencies }
102
85
} )
103
86
104
87
api . render ( './templates/common' )
88
+
105
89
if ( opts . quasar . rtlSupport ) {
106
90
api . render ( './templates/rtl' )
107
91
}
92
+
108
93
if ( opts . quasar . replaceComponents ) {
109
94
const extension = hasTS ? 'ts' : 'js' ,
110
95
routerFile = api . resolve ( `src/router.${ extension } ` ) ,
111
96
hasRouter = fs . existsSync ( routerFile )
112
97
113
98
api . render ( `./templates/with${ hasRouter ? '' : 'out' } -router-base` , opts )
114
99
api . render (
115
- `./templates/with${ hasRouter ? '' : 'out' } -router-${
116
- opts . quasar . v1 ? 'v1' : 'legacy'
117
- } `,
100
+ `./templates/with${ hasRouter ? '' : 'out' } -router` ,
118
101
opts
119
102
)
120
103
if ( hasRouter ) {
@@ -123,14 +106,15 @@ module.exports = (api, opts, rootOpts) => {
123
106
}
124
107
125
108
api . onCreateComplete ( ( ) => {
126
- if ( ! opts . quasar . all ) {
127
- extendBabel ( api , opts . quasar )
109
+ if ( opts . quasar . treeShake ) {
110
+ extendBabel ( api )
128
111
}
129
112
130
- let lines = '\n'
113
+ const
114
+ hasIconSet = opts . quasar . iconSet !== 'material-icons' ,
115
+ hasLang = opts . quasar . lang !== 'en-us'
131
116
132
- const hasLang = opts . quasar . i18n !== 'en-us' ,
133
- hasIconSet = opts . quasar . iconSet !== 'material-icons'
117
+ let lines = '\n'
134
118
135
119
if ( ! opts . quasar . features . includes ( opts . quasar . iconSet ) ) {
136
120
opts . quasar . features . push ( opts . quasar . iconSet )
@@ -139,56 +123,28 @@ module.exports = (api, opts, rootOpts) => {
139
123
lines += `\nimport './styles/quasar.styl'`
140
124
141
125
if ( opts . quasar . features . includes ( 'ie' ) ) {
142
- lines += `\nimport 'quasar${
143
- opts . quasar . v1 ? '' : '-framework'
144
- } /dist/quasar.ie.polyfills'`
126
+ lines += `\nimport 'quasar/dist/quasar.ie.polyfills'`
145
127
}
146
- const v1IconsMap = {
147
- 'material-icons' : 'material-icons' ,
148
- ionicons : 'ionicons-v4' ,
149
- fontawesome : 'fontawesome-v5' ,
150
- mdi : 'mdi-v3'
151
- }
152
- // Return either legacy or v1 name
153
- const getIconSetName = name => ( opts . quasar . v1 ? v1IconsMap [ name ] : name )
128
+
154
129
if ( hasIconSet ) {
155
- lines += `\nimport iconSet from 'quasar${
156
- opts . quasar . v1 ? '' : '-framework'
157
- } /${ opts . quasar . v1 ? 'icon-set' : 'icons' } /${ getIconSetName (
158
- opts . quasar . iconSet
159
- ) } '`
130
+ const set = iconMap [ opts . quasar . iconSet ] || opts . quasar . iconSet
131
+ lines += `\nimport iconSet from 'quasar/icon-set/${ set } .js'`
160
132
}
133
+
161
134
if ( hasLang ) {
162
- lines += `\nimport lang from 'quasar${
163
- opts . quasar . v1 ? '' : '-framework'
164
- } /i18n/${ opts . quasar . i18n } '`
135
+ lines += `\nimport lang from 'quasar/lang/${ opts . quasar . lang } .js'`
165
136
}
166
- const iconSets = [
167
- 'material-icons' ,
168
- 'fontawesome-v5' ,
169
- 'mdi-v3' ,
170
- 'ionicons-v4' ,
171
- 'fontawesome' ,
172
- 'mdi' ,
173
- 'ionicons'
174
- ]
137
+
175
138
opts . quasar . features
176
139
. filter ( feat => feat !== 'ie' )
177
140
. forEach ( feat => {
178
- if ( iconSets . includes ( feat ) ) feat = getIconSetName ( feat )
179
- lines += `\nimport '${
180
- opts . quasar . v1 ? '@quasar/extras' : 'quasar-extras'
181
- } /${ feat } ${
182
- // Path must be iconpack/iconpack.css with @quasar /extras
183
- iconSets . includes ( feat ) && opts . quasar . v1 ? `/${ feat } .css` : ''
184
- } '`
141
+ feat = iconMap [ feat ] || feat
142
+ lines += `\nimport '@quasar/extras/${ feat } /${ feat } .css'`
185
143
} )
186
144
187
145
// build import
188
146
lines += `\nimport `
189
- if ( opts . quasar . all ) {
190
- lines += `Quasar`
191
- } else {
147
+ if ( opts . quasar . treeShake ) {
192
148
lines += `{\n Quasar, `
193
149
components
194
150
. concat ( directives )
@@ -197,15 +153,17 @@ module.exports = (api, opts, rootOpts) => {
197
153
lines += `\n ${ part } ,`
198
154
} )
199
155
lines += `\n}`
156
+ } else {
157
+ lines += `Quasar`
200
158
}
201
159
lines += ` from 'quasar'`
202
160
203
161
// build Vue.use()
204
162
lines += `\n\nVue.use(Quasar, {`
205
163
lines += `\n config: {}`
206
164
207
- // if not 'all' we want to include specific defaults
208
- if ( ! opts . quasar . all ) {
165
+ // if tree-shake was chosen then we want to include specific defaults
166
+ if ( opts . quasar . treeShake ) {
209
167
lines += ',\n components: {'
210
168
components . forEach ( part => {
211
169
lines += `\n ${ part } ,`
@@ -226,10 +184,10 @@ module.exports = (api, opts, rootOpts) => {
226
184
}
227
185
228
186
if ( hasLang ) {
229
- lines += `, i18n : lang`
187
+ lines += `,\n lang : lang`
230
188
}
231
189
if ( hasIconSet ) {
232
- lines += `, iconSet: iconSet`
190
+ lines += `,\n iconSet: iconSet`
233
191
}
234
192
235
193
lines += `\n })`
0 commit comments