@@ -3,67 +3,55 @@ const fs = require('fs'),
33 extendBabel = require ( '../lib/extendBabel' )
44
55const message = `
6- Documentation can be found at: https://quasar-framework.org
6+ Documentation can be found at: https://v1. quasar-framework.org
77
88Quasar is relying on donations to evolve. We'd be very grateful if you can
99take a look at: https://www.patreon.com/quasarframework
1010Any 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
1212
1313Please give us a star on Github if you appreciate our work:
1414https://github.com/quasarframework/quasar
1515
1616Enjoy! - Quasar Team
1717`
1818
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' ) ,
5647 jsPath = api . resolve ( './src/main.js' ) ,
5748 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+
6755 const deps = {
6856 dependencies,
6957 devDependencies : {
@@ -81,40 +69,35 @@ module.exports = (api, opts, rootOpts) => {
8169
8270 // modify plugin options
8371 extendPluginOptions ( api , ( pluginOptions , transpileDependencies ) => {
84- pluginOptions . quasar = {
85- theme : opts . quasar . theme
86- }
72+ pluginOptions . quasar = pluginOptions . quasar || { }
73+
8774 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
9276 }
93- if ( opts . quasar . v1 ) {
94- pluginOptions . quasar . v1 = true
77+
78+ if ( opts . quasar . treeShake ) {
79+ pluginOptions . quasar . treeShake = opts . quasar . treeShake
9580 }
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 [ \\ / ] / )
10083
10184 return { pluginOptions, transpileDependencies }
10285 } )
10386
10487 api . render ( './templates/common' )
88+
10589 if ( opts . quasar . rtlSupport ) {
10690 api . render ( './templates/rtl' )
10791 }
92+
10893 if ( opts . quasar . replaceComponents ) {
10994 const extension = hasTS ? 'ts' : 'js' ,
11095 routerFile = api . resolve ( `src/router.${ extension } ` ) ,
11196 hasRouter = fs . existsSync ( routerFile )
11297
11398 api . render ( `./templates/with${ hasRouter ? '' : 'out' } -router-base` , opts )
11499 api . render (
115- `./templates/with${ hasRouter ? '' : 'out' } -router-${
116- opts . quasar . v1 ? 'v1' : 'legacy'
117- } `,
100+ `./templates/with${ hasRouter ? '' : 'out' } -router` ,
118101 opts
119102 )
120103 if ( hasRouter ) {
@@ -123,14 +106,15 @@ module.exports = (api, opts, rootOpts) => {
123106 }
124107
125108 api . onCreateComplete ( ( ) => {
126- if ( ! opts . quasar . all ) {
127- extendBabel ( api , opts . quasar )
109+ if ( opts . quasar . treeShake ) {
110+ extendBabel ( api )
128111 }
129112
130- let lines = '\n'
113+ const
114+ hasIconSet = opts . quasar . iconSet !== 'material-icons' ,
115+ hasLang = opts . quasar . lang !== 'en-us'
131116
132- const hasLang = opts . quasar . i18n !== 'en-us' ,
133- hasIconSet = opts . quasar . iconSet !== 'material-icons'
117+ let lines = '\n'
134118
135119 if ( ! opts . quasar . features . includes ( opts . quasar . iconSet ) ) {
136120 opts . quasar . features . push ( opts . quasar . iconSet )
@@ -139,56 +123,28 @@ module.exports = (api, opts, rootOpts) => {
139123 lines += `\nimport './styles/quasar.styl'`
140124
141125 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'`
145127 }
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+
154129 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'`
160132 }
133+
161134 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'`
165136 }
166- const iconSets = [
167- 'material-icons' ,
168- 'fontawesome-v5' ,
169- 'mdi-v3' ,
170- 'ionicons-v4' ,
171- 'fontawesome' ,
172- 'mdi' ,
173- 'ionicons'
174- ]
137+
175138 opts . quasar . features
176139 . filter ( feat => feat !== 'ie' )
177140 . 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'`
185143 } )
186144
187145 // build import
188146 lines += `\nimport `
189- if ( opts . quasar . all ) {
190- lines += `Quasar`
191- } else {
147+ if ( opts . quasar . treeShake ) {
192148 lines += `{\n Quasar, `
193149 components
194150 . concat ( directives )
@@ -197,15 +153,17 @@ module.exports = (api, opts, rootOpts) => {
197153 lines += `\n ${ part } ,`
198154 } )
199155 lines += `\n}`
156+ } else {
157+ lines += `Quasar`
200158 }
201159 lines += ` from 'quasar'`
202160
203161 // build Vue.use()
204162 lines += `\n\nVue.use(Quasar, {`
205163 lines += `\n config: {}`
206164
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 ) {
209167 lines += ',\n components: {'
210168 components . forEach ( part => {
211169 lines += `\n ${ part } ,`
@@ -226,10 +184,10 @@ module.exports = (api, opts, rootOpts) => {
226184 }
227185
228186 if ( hasLang ) {
229- lines += `, i18n : lang`
187+ lines += `,\n lang : lang`
230188 }
231189 if ( hasIconSet ) {
232- lines += `, iconSet: iconSet`
190+ lines += `,\n iconSet: iconSet`
233191 }
234192
235193 lines += `\n })`
0 commit comments