Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.

Commit bd6ec82

Browse files
committed
feat(presets): add default preset option
connect vuetify-loader for a-la-carte
1 parent 3540267 commit bd6ec82

File tree

8 files changed

+946
-46
lines changed

8 files changed

+946
-46
lines changed

generator/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
const defaults = {
2+
preset: 'configure',
3+
replaceComponents: true,
4+
useTheme: false,
5+
useCustomProperties: false,
6+
iconFont: 'md',
7+
installFonts: false,
8+
useAlaCarte: true,
9+
usePolyfill: true,
10+
locale: 'en'
11+
}
12+
113
module.exports = (api, opts, rootOpts) => {
214
const alaCarte = require('./tools/alaCarte')
315
const fonts = require('./tools/fonts')
416
const polyfill = require('./tools/polyfill')
517
const vuetify = require('./tools/vuetify')
618

19+
opts = opts.preset === 'default'
20+
? defaults
21+
: opts
22+
723
vuetify.addDependencies(api)
824
opts.useAlaCarte && alaCarte.addDependencies(api)
925
opts.usePolyfill && polyfill.addDependencies(api)

generator/templates/default/src/components/HelloWorld.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
>
77
<v-flex xs12>
88
<v-img
9+
:src="require('../assets/logo.svg')"
910
class="my-3"
1011
contain
1112
height="200"
@@ -123,18 +124,19 @@
123124
}
124125
],
125126
whatsNext: [
127+
{
128+
text: 'Explore components',
129+
href: 'https://vuetifyjs.com/components/api-explorer'
130+
},
126131
{
127132
text: 'Select a layout',
128133
href: 'https://vuetifyjs.com/layout/pre-defined'
129134
},
130135
{
131136
text: 'Frequently Asked Questions',
132137
href: 'https://vuetifyjs.com/getting-started/frequently-asked-questions'
133-
},
134-
{
135-
text: 'Explore components',
136-
href: 'https://vuetifyjs.com/components/api-explorer'
137138
}
139+
138140
]
139141
})
140142
}

generator/templates/default/src/plugins/vuetify.js

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
11
import Vue from 'vue'
22
<%_ if (useAlaCarte) { _%>
3-
// For information on how to automate this process
4-
// Checkout https://vuetifyjs.com/guides/a-la-carte#vuetify-loader
5-
6-
import Vuetify, {
7-
VApp,
8-
VBtn,
9-
VContainer,
10-
VContent,
11-
VFlex,
12-
VFooter,
13-
VIcon,
14-
VImg,
15-
VLayout,
16-
VNavigationDrawer,
17-
VSpacer,
18-
VToolbar,
19-
VToolbarTitle
20-
} from 'vuetify/lib'
3+
import Vuetify from 'vuetify/lib'
214
import 'vuetify/src/stylus/app.styl'
225
<%_ } else { _%>
236
import Vuetify from 'vuetify'
@@ -28,23 +11,6 @@ import <%= locale.replace(/-/g, '') %> from 'vuetify/<%= typescript ? 'src' : 'e
2811
<%_ } _%>
2912

3013
Vue.use(Vuetify, {
31-
<%_ if (useAlaCarte) { _%>
32-
components: {
33-
VApp,
34-
VBtn,
35-
VContainer,
36-
VContent,
37-
VFlex,
38-
VFooter,
39-
VIcon,
40-
VImg,
41-
VLayout,
42-
VNavigationDrawer,
43-
VSpacer,
44-
VToolbar,
45-
VToolbarTitle
46-
},
47-
<%_ } _%>
4814
<%_ if (useTheme) { _%>
4915
theme: {
5016
primary: '#ee44aa',

generator/tools/alaCarte.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
function addDependencies (api) {
22
api.extendPackage({
33
devDependencies: {
4+
"vuetify-loader": "^1.0.5",
45
"stylus": "^0.54.5",
56
"stylus-loader": "^3.0.1",
67
}

index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
module.exports = (api, opts) => {}
1+
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin')
2+
3+
module.exports = (api, opts) => {
4+
const hasVuetifyLoader = Boolean(
5+
api.service.pkg.devDependencies['vuetify-loader'] ||
6+
api.service.pkg.dependencies['vuetify-loader']
7+
)
8+
9+
if (hasVuetifyLoader) {
10+
api.configureWebpack(webpackConfig => {
11+
webpackConfig.plugins.push(new VuetifyLoaderPlugin())
12+
})
13+
}
14+
}

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
},
2525
"homepage": "https://github.com/vuetifyjs/vue-cli-plugin-vuetify#readme",
2626
"devDependencies": {
27-
"@vue/cli-service": "^3.0.1"
28-
}
27+
"@vue/cli-service": "^3.0.1",
28+
"vuetify-loader": "^1.0.5"
29+
},
30+
"dependencies": {}
2931
}

prompts.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
1+
function isCustom (answers) {
2+
return answers.preset === 'configure'
3+
}
4+
15
module.exports = [
6+
{
7+
name: 'preset',
8+
type: 'list',
9+
choices: [
10+
{ name: 'default (recommended)', value: 'default' },
11+
{ name: 'configure', value: 'configure' }
12+
],
13+
default: 'default'
14+
},
215
{
316
name: 'replaceComponents',
417
type: 'confirm',
518
message: 'Use a pre-made template? (will replace App.vue and HelloWorld.vue)',
619
default: true,
20+
when: isCustom
721
},
822
{
923
name: 'useTheme',
1024
type: 'confirm',
1125
message: 'Use custom theme?',
1226
default: false,
27+
when: isCustom
1328
},
1429
{
1530
name: 'useCustomProperties',
1631
type: 'confirm',
1732
message: 'Use custom properties (CSS variables)?',
1833
default: false,
34+
when: isCustom
1935
},
2036
{
2137
name: 'iconFont',
@@ -35,25 +51,29 @@ module.exports = [
3551
'Font Awesome 5': 'fa',
3652
'Font Awesome 4': 'fa4',
3753
}[val]
38-
}
54+
},
55+
when: isCustom
3956
},
4057
{
4158
name: 'installFonts',
4259
type: 'confirm',
4360
message: 'Use fonts as a dependency (for Electron or offline)?',
4461
default: false,
62+
when: isCustom
4563
},
4664
{
4765
name: 'useAlaCarte',
4866
type: 'confirm',
4967
message: 'Use a-la-carte components?',
50-
default: false,
68+
default: true,
69+
when: isCustom
5170
},
5271
{
5372
name: 'usePolyfill',
5473
type: 'confirm',
5574
message: 'Use babel/polyfill?',
56-
default: true
75+
default: true,
76+
when: isCustom
5777
},
5878
{
5979
name: 'locale',
@@ -93,6 +113,7 @@ module.exports = [
93113
'Ukrainian': 'uk',
94114
'Serbian (cyrillic)': 'sr-Cyrl',
95115
}[val]
96-
}
116+
},
117+
when: isCustom
97118
}
98119
]

0 commit comments

Comments
 (0)