Skip to content

Commit

Permalink
feat: add preset support (#247)
Browse files Browse the repository at this point in the history
* feat: add preset support

* feat: add preset support

* fix lint

* fix: fix options order

* fix: fix other orders

Co-authored-by: Kevin Marrec <kevin@marrec.io>
  • Loading branch information
aldarund and kevinmarrec committed Jan 10, 2020
1 parent 003f372 commit 25d9813
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default function setupBuild (this: ModuleThis, options: Options) {
delete vuetifyOptions.customVariables
delete vuetifyOptions.defaultAssets
delete vuetifyOptions.optionsPath
delete vuetifyOptions.preset
delete vuetifyOptions.treeShake

let optionsPath: string | null = this.nuxt.resolver.resolveAlias(options.optionsPath ||
Expand All @@ -44,6 +45,7 @@ export default function setupBuild (this: ModuleThis, options: Options) {
src: path.resolve(__dirname, '../templates', 'plugin.js'),
options: {
defaultIconPreset: options.defaultAssets && options.defaultAssets.icons,
preset: options.preset,
treeShake: options.treeShake
}
})
Expand Down
1 change: 1 addition & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface Options extends Partial<VuetifyPreset> {
icons?: IconPreset | false
} | false
optionsPath?: string
preset?: string
treeShake?: boolean | TreeShakeOptions
}

Expand Down
7 changes: 7 additions & 0 deletions templates/plugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import Vue from 'vue'
import Vuetify from '<%= options.treeShake ? 'vuetify/lib' : 'vuetify' %>'
<% if (options.preset) { %>
import { preset } from '<%= options.preset %>'
<% } %>

<%
const libImports = [
{ key: 'components', location: 'vuetify/lib'},
Expand Down Expand Up @@ -34,6 +38,9 @@ export default (ctx) => {
vuetifyOptions.icons = vuetifyOptions.icons || {}
vuetifyOptions.icons.iconfont = '<%= options.defaultIconPreset %>'
<% } %>
<% if (options.preset) { %>
vuetifyOptions.preset = preset
<% } %>

const vuetify = new Vuetify(vuetifyOptions)

Expand Down

0 comments on commit 25d9813

Please sign in to comment.