11const fs = require ( 'fs' )
22const extendPluginOptions = require ( '../lib/extendPluginOptions' )
3-
43const message = `
54Documentation can be found at: http://quasar-framework.org
65
@@ -16,6 +15,26 @@ Enjoy! - Quasar Team
1615`
1716
1817module . exports = ( api , opts , rootOpts ) => {
18+ const
19+ defaultComponents = [
20+ 'QBtn' ,
21+ 'QLayout' ,
22+ 'QLayoutHeader' ,
23+ 'QLayoutDrawer' ,
24+ 'QPage' ,
25+ 'QPageContainer' ,
26+ 'QToolbar' ,
27+ 'QToolbarTitle' ,
28+ 'QList' ,
29+ 'QListHeader' ,
30+ 'QItemSeparator' ,
31+ 'QItem' ,
32+ 'QItemSide' ,
33+ 'QItemMain' ,
34+ ] ,
35+ defaultDirectives = [ ] ,
36+ defaultPlugins = [ ]
37+
1938 const
2039 tsPath = api . resolve ( './src/main.ts' ) ,
2140 jsPath = api . resolve ( './src/main.js' ) ,
@@ -27,8 +46,9 @@ module.exports = (api, opts, rootOpts) => {
2746 'quasar-extras' : '^2.0.4'
2847 } ,
2948 devDependencies : {
49+ "babel-plugin-transform-imports" : "1.5.0" ,
3050 'stylus' : '^0.54.5' ,
31- 'stylus-loader' : '^3.0.1 '
51+ 'stylus-loader' : '^3.0.2 '
3252 }
3353 }
3454
@@ -46,6 +66,15 @@ module.exports = (api, opts, rootOpts) => {
4666 if ( opts . quasar . rtlSupport ) {
4767 pluginOptions . quasar . rtlSupport = true
4868 }
69+
70+ if ( opts . quasar . all ) {
71+ pluginOptions . quasar . framework = 'all'
72+ } else {
73+ pluginOptions . quasar . framework = { }
74+ pluginOptions . quasar . framework . components = defaultComponents
75+ pluginOptions . quasar . framework . directives = defaultDirectives
76+ pluginOptions . quasar . framework . plugins = defaultPlugins
77+ }
4978 return pluginOptions
5079 } )
5180
@@ -69,24 +98,9 @@ module.exports = (api, opts, rootOpts) => {
6998 let lines = '\n'
7099
71100 const
72- components = [
73- 'QBtn' ,
74- 'QLayout' ,
75- 'QLayoutHeader' ,
76- 'QLayoutDrawer' ,
77- 'QPage' ,
78- 'QPageContainer' ,
79- 'QToolbar' ,
80- 'QToolbarTitle' ,
81- 'QList' ,
82- 'QListHeader' ,
83- 'QItemSeparator' ,
84- 'QItem' ,
85- 'QItemSide' ,
86- 'QItemMain' ,
87- ] ,
88- directives = [ ] ,
89- plugins = [ ]
101+ components = defaultComponents ,
102+ directives = defaultDirectives ,
103+ plugins = defaultPlugins
90104
91105 const
92106 hasLang = opts . quasar . i18n !== 'en-us' ,
@@ -114,53 +128,49 @@ module.exports = (api, opts, rootOpts) => {
114128 lines += `\nimport 'quasar-extras/${ feat } '`
115129 } )
116130
117- lines += `\nimport Quasar, `
131+ // build import
132+ lines += `\nimport `
118133 if ( opts . quasar . all ) {
119- lines += `* as All `
134+ lines += `Quasar `
120135 }
121136 else {
122- lines += `{`
137+ lines += `{\n Quasar, `
123138 components . concat ( directives ) . concat ( plugins )
124139 . forEach ( part => { lines += `\n ${ part } ,` } )
125140 lines += `\n}`
126141 }
127142 lines += ` from 'quasar'`
128143
144+ // build Vue.use()
129145 lines += `\n\nVue.use(Quasar, {`
130- if ( hasIconSet ) {
131- lines += `\n iconSet: iconSet,`
132- }
133- if ( hasLang ) {
134- lines += `\n i18n: lang,`
135- }
146+ lines += opts . quasar . all ? ` config: {}` : `\n config: {}`
136147
137- if ( opts . quasar . all ) {
138- lines += `\n components: All,`
139- lines += `\n directives: All,`
140- lines += `\n plugins: All`
141- }
142- else {
143- lines += `\n components: {`
144- components . forEach ( comp => {
145- lines += `\n ${ comp } ,`
146- } )
147- lines += `\n },`
148+ // if not 'all' we want to include specific defaults
149+ if ( ! opts . quasar . all ) {
150+ lines += ',\n components: {'
151+ components
152+ . forEach ( part => { lines += `\n ${ part } ,` } )
153+ lines += `\n }`
148154
149- lines += `\n directives: {`
150- directives . forEach ( directive => {
151- lines += `\n ${ directive } ,`
152- } )
153- lines += `\n },`
155+ lines += ',\n directives: {'
156+ directives
157+ . forEach ( part => { lines += `\n ${ part } ,` } )
158+ lines += `\n }`
154159
155- lines += `\n plugins: {`
156- plugins . forEach ( plugin => {
157- lines += `\n ${ plugin } ,`
158- } )
160+ lines += ',\n plugins: {'
161+ plugins
162+ . forEach ( part => { lines += `\n ${ part } ,` } )
159163 lines += `\n }`
160164 }
161165
162- lines += `\n})`
166+ if ( hasLang ) {
167+ lines += `, i18n: lang`
168+ }
169+ if ( hasIconSet ) {
170+ lines += `, iconSet: iconSet`
171+ }
163172
173+ lines += ` })`
164174
165175 // Now inject additions to main.[js|ts]
166176 {
0 commit comments