Skip to content

Commit

Permalink
fix(LICENSE.md): add license file
Browse files Browse the repository at this point in the history
fixes #115
  • Loading branch information
johnleider committed Oct 6, 2019
1 parent 87ef833 commit 4e84c85
Show file tree
Hide file tree
Showing 6 changed files with 531 additions and 368 deletions.
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2016-2019 John Jeremy Leider

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13 changes: 10 additions & 3 deletions generator/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Imports
const shell = require('shelljs')

module.exports = (api, opts) => {
const alaCarte = require('./tools/alaCarte')
const fonts = require('./tools/fonts')
Expand All @@ -19,9 +22,7 @@ module.exports = (api, opts) => {
if (opts.useAlaCarte) alaCarte.addDependencies(api)
else if (opts.usePolyfill) polyfill.addDependencies(api)

if (opts.installFonts) {
fonts.addDependencies(api, opts.iconFont)
}
if (opts.installFonts) fonts.addDependencies(api, opts.iconFont)

// Update templates
vuetify.renderFiles(api, opts)
Expand All @@ -34,5 +35,11 @@ module.exports = (api, opts) => {
}
if (!opts.installFonts) fonts.addLinks(api, opts.iconFont)
vuetify.setHtmlLang(api, opts.locale)

// Update vue.config.js for transpileDependency
vuetify.updateOrCreateVueConfig(api)

// lint & fix after create to ensure files adhere to chosen config
shell.exec('npm run lint --fix')
})
}
25 changes: 24 additions & 1 deletion generator/tools/vuetify.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Imports
const fs = require('fs')
const helpers = require('./helpers')

function addDependencies (api) {
api.extendPackage({
dependencies: {
vuetify: "^2.0.0"
vuetify: "^2.1.0"
}
})
}
Expand Down Expand Up @@ -56,9 +58,30 @@ function setHtmlLang (api, locale) {
})
}

function updateOrCreateVueConfig (api) {
const config = api.resolve('vue.config.js')

if (!fs.existsSync(config)) {
fs.writeFileSync(config, 'module.exports = {}', 'utf8')
}

const file = require(config)

if (!file.transpileDependencies) {
file.transpileDependencies = []
}

if (!file.transpileDependencies.includes('vuetify')) {
file.transpileDependencies.push('vuetify')
}

fs.writeFileSync(config, `module.exports = ${JSON.stringify(file, 2, 2)}`, 'utf8')
}

module.exports = {
addDependencies,
addImports,
renderFiles,
setHtmlLang,
updateOrCreateVueConfig,
}
51 changes: 36 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
const fs = require('fs')
const path = require('path')

function resolve (dir) {
return path.join(__dirname, '..', dir)
}

module.exports = (api, opts) => {
function mergeRules (opt, sass = true, type) {
const end = sass ? "'" : "';"

opt.data = `@import '~vuetify/src/styles/styles.sass${end}`
opt.data += `\n@import '@/sass/variables.${type}${end}`

return opt
}

module.exports = (api) => {
const hasVuetifyLoader = Boolean(
api.service.pkg.devDependencies['vuetify-loader'] ||
api.service.pkg.dependencies['vuetify-loader']
Expand All @@ -13,21 +23,9 @@ module.exports = (api, opts) => {
if (hasVuetifyLoader) {
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin')

// As the vuetify-loader automatically imports the necessary Vuetify components they are not found and
// transpiled by Babel. Add Vuetify explicitly as a module to be transpiled.
if (opts.transpileDependencies.indexOf('vuetify') === -1) {
api.chainWebpack(config => {
config.module
.rule('js')
.test(/\.m?jsx?$/)
.include
.add(resolve('vuetify'))
.end()
})
}

api.chainWebpack(config => {
config.plugin('VuetifyLoaderPlugin')
config
.plugin('VuetifyLoaderPlugin')
.use(VuetifyLoaderPlugin)
})
}
Expand All @@ -51,4 +49,27 @@ module.exports = (api, opts) => {
},
}))
})

// Bootstrap SASS Variables
let type
const hasSassVariables = fs.existsSync(api.resolve('src/sass/variables.sass'))
const hasScssVariables = fs.existsSync(api.resolve('src/sass/variables.scss'))

if (!hasSassVariables && !hasScssVariables) return

type = hasSassVariables ? 'sass' : 'scss'

api.chainWebpack(config => {
['vue-modules', 'vue', 'normal-modules', 'normal'].forEach(match => {
for (let i = 0; i < 2; i++) {
const boolean = Boolean(i)

config.module
.rule(boolean ? 'sass' : 'scss')
.oneOf(match)
.use('sass-loader')
.tap(opt => mergeRules(opt, boolean, type))
}
})
})
}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
"homepage": "https://github.com/vuetifyjs/vue-cli-plugin-vuetify#readme",
"devDependencies": {
"@release-it/conventional-changelog": "^1.1.0",
"@vue/cli-service": "^3.8.0",
"vuetify": "^2.0.0",
"@vue/cli-service": "^3.11.0",
"vuetify": "^2.1.0",
"vuetify-loader": "^1.2.2"
},
"dependencies": {}
"dependencies": {
"shelljs": "^0.8.3"
}
}

0 comments on commit 4e84c85

Please sign in to comment.