Skip to content

Commit 4e84c85

Browse files
committed
fix(LICENSE.md): add license file
fixes #115
1 parent 87ef833 commit 4e84c85

File tree

6 files changed

+531
-368
lines changed

6 files changed

+531
-368
lines changed

LICENSE.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016-2019 John Jeremy Leider
4+
5+
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:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
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.

generator/index.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Imports
2+
const shell = require('shelljs')
3+
14
module.exports = (api, opts) => {
25
const alaCarte = require('./tools/alaCarte')
36
const fonts = require('./tools/fonts')
@@ -19,9 +22,7 @@ module.exports = (api, opts) => {
1922
if (opts.useAlaCarte) alaCarte.addDependencies(api)
2023
else if (opts.usePolyfill) polyfill.addDependencies(api)
2124

22-
if (opts.installFonts) {
23-
fonts.addDependencies(api, opts.iconFont)
24-
}
25+
if (opts.installFonts) fonts.addDependencies(api, opts.iconFont)
2526

2627
// Update templates
2728
vuetify.renderFiles(api, opts)
@@ -34,5 +35,11 @@ module.exports = (api, opts) => {
3435
}
3536
if (!opts.installFonts) fonts.addLinks(api, opts.iconFont)
3637
vuetify.setHtmlLang(api, opts.locale)
38+
39+
// Update vue.config.js for transpileDependency
40+
vuetify.updateOrCreateVueConfig(api)
41+
42+
// lint & fix after create to ensure files adhere to chosen config
43+
shell.exec('npm run lint --fix')
3744
})
3845
}

generator/tools/vuetify.js

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
// Imports
2+
const fs = require('fs')
13
const helpers = require('./helpers')
24

35
function addDependencies (api) {
46
api.extendPackage({
57
dependencies: {
6-
vuetify: "^2.0.0"
8+
vuetify: "^2.1.0"
79
}
810
})
911
}
@@ -56,9 +58,30 @@ function setHtmlLang (api, locale) {
5658
})
5759
}
5860

61+
function updateOrCreateVueConfig (api) {
62+
const config = api.resolve('vue.config.js')
63+
64+
if (!fs.existsSync(config)) {
65+
fs.writeFileSync(config, 'module.exports = {}', 'utf8')
66+
}
67+
68+
const file = require(config)
69+
70+
if (!file.transpileDependencies) {
71+
file.transpileDependencies = []
72+
}
73+
74+
if (!file.transpileDependencies.includes('vuetify')) {
75+
file.transpileDependencies.push('vuetify')
76+
}
77+
78+
fs.writeFileSync(config, `module.exports = ${JSON.stringify(file, 2, 2)}`, 'utf8')
79+
}
80+
5981
module.exports = {
6082
addDependencies,
6183
addImports,
6284
renderFiles,
6385
setHtmlLang,
86+
updateOrCreateVueConfig,
6487
}

index.js

+36-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1+
const fs = require('fs')
12
const path = require('path')
23

34
function resolve (dir) {
45
return path.join(__dirname, '..', dir)
56
}
67

7-
module.exports = (api, opts) => {
8+
function mergeRules (opt, sass = true, type) {
9+
const end = sass ? "'" : "';"
10+
11+
opt.data = `@import '~vuetify/src/styles/styles.sass${end}`
12+
opt.data += `\n@import '@/sass/variables.${type}${end}`
13+
14+
return opt
15+
}
16+
17+
module.exports = (api) => {
818
const hasVuetifyLoader = Boolean(
919
api.service.pkg.devDependencies['vuetify-loader'] ||
1020
api.service.pkg.dependencies['vuetify-loader']
@@ -13,21 +23,9 @@ module.exports = (api, opts) => {
1323
if (hasVuetifyLoader) {
1424
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin')
1525

16-
// As the vuetify-loader automatically imports the necessary Vuetify components they are not found and
17-
// transpiled by Babel. Add Vuetify explicitly as a module to be transpiled.
18-
if (opts.transpileDependencies.indexOf('vuetify') === -1) {
19-
api.chainWebpack(config => {
20-
config.module
21-
.rule('js')
22-
.test(/\.m?jsx?$/)
23-
.include
24-
.add(resolve('vuetify'))
25-
.end()
26-
})
27-
}
28-
2926
api.chainWebpack(config => {
30-
config.plugin('VuetifyLoaderPlugin')
27+
config
28+
.plugin('VuetifyLoaderPlugin')
3129
.use(VuetifyLoaderPlugin)
3230
})
3331
}
@@ -51,4 +49,27 @@ module.exports = (api, opts) => {
5149
},
5250
}))
5351
})
52+
53+
// Bootstrap SASS Variables
54+
let type
55+
const hasSassVariables = fs.existsSync(api.resolve('src/sass/variables.sass'))
56+
const hasScssVariables = fs.existsSync(api.resolve('src/sass/variables.scss'))
57+
58+
if (!hasSassVariables && !hasScssVariables) return
59+
60+
type = hasSassVariables ? 'sass' : 'scss'
61+
62+
api.chainWebpack(config => {
63+
['vue-modules', 'vue', 'normal-modules', 'normal'].forEach(match => {
64+
for (let i = 0; i < 2; i++) {
65+
const boolean = Boolean(i)
66+
67+
config.module
68+
.rule(boolean ? 'sass' : 'scss')
69+
.oneOf(match)
70+
.use('sass-loader')
71+
.tap(opt => mergeRules(opt, boolean, type))
72+
}
73+
})
74+
})
5475
}

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
"homepage": "https://github.com/vuetifyjs/vue-cli-plugin-vuetify#readme",
2929
"devDependencies": {
3030
"@release-it/conventional-changelog": "^1.1.0",
31-
"@vue/cli-service": "^3.8.0",
32-
"vuetify": "^2.0.0",
31+
"@vue/cli-service": "^3.11.0",
32+
"vuetify": "^2.1.0",
3333
"vuetify-loader": "^1.2.2"
3434
},
35-
"dependencies": {}
35+
"dependencies": {
36+
"shelljs": "^0.8.3"
37+
}
3638
}

0 commit comments

Comments
 (0)