Skip to content

Commit eb7cbcc

Browse files
authored
Fix/append data vue config (#30)
* chore: add .vscode to gitignore * fix(templates): scss: import all bootstrap by default * chore: add lodash dep * feat: add choice to inject vars, funcs & mixins the user can choice if inject bootstrap's scss vars, functions & mixins in sfc components
1 parent ddc3b15 commit eb7cbcc

File tree

7 files changed

+126
-115
lines changed

7 files changed

+126
-115
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ typings/
5959

6060
# next.js build output
6161
.next
62+
.vscode

bootstrapCssAbstractsImports.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = [
2+
'@import "~bootstrap/scss/_functions.scss"',
3+
'@import "~@/assets/scss/vendors/bootstrap-vue/_custom.scss"',
4+
'@import "~bootstrap/scss/_variables.scss"',
5+
'@import "~bootstrap/scss/_mixins.scss"',
6+
'@import "~bootstrap-vue/src/_variables.scss"',
7+
]
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import Vue from 'vue'
22

3-
// import BootstrapVue from 'bootstrap-vue'
4-
import { ButtonPlugin } from 'bootstrap-vue'
3+
import BootstrapVue from 'bootstrap-vue'
54

6-
// Vue.use(BootstrapVue)
7-
Vue.use(ButtonPlugin)
5+
Vue.use(BootstrapVue)

index.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
const { merge } = require('lodash/object')
2+
const bootstrapCssAbstractsImports = require('./bootstrapCssAbstractsImports')
3+
14
module.exports = (api, opts) => {
25
// Resolve asset references from components
36
api.chainWebpack(config => {
@@ -29,23 +32,17 @@ module.exports = (api, opts) => {
2932
})
3033
})
3134

32-
//Add bootstrap's variables globally
33-
const bootstrapVueVarImports = [
34-
'@import "~bootstrap/scss/_functions.scss"',
35-
'@import "~@/assets/scss/vendors/bootstrap-vue/_custom.scss"',
36-
'@import "~bootstrap/scss/_variables.scss"',
37-
'@import "~bootstrap/scss/_mixins.scss"',
38-
'@import "~bootstrap-vue/src/_variables.scss"',
39-
]
40-
41-
//add custom variables
42-
opts.css.loaderOptions = {
35+
//Add bootstrap's variables/functions/mixins globally
36+
if(opts.useScss && opts.injectAbstracts){
37+
merge(opts.css, {
38+
loaderOptions:{
4339
sass: {
44-
additionalData: bootstrapVueVarImports.join('\n')
40+
additionalData: bootstrapCssAbstractsImports.join('\n')
4541
},
4642
scss: {
47-
additionalData: [...bootstrapVueVarImports, ''].join(';\n')
43+
additionalData: [...bootstrapCssAbstractsImports, ''].join(';\n')
4844
}
4945
}
50-
46+
})
47+
}
5148
}

package-lock.json

Lines changed: 95 additions & 97 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@
3333
"homepage": "https://github.com/GregYankovoy/vue-cli-plugin-bootstrap-vue#readme",
3434
"devDependencies": {
3535
"@vue/cli-service": "^4.5.6"
36+
},
37+
"dependencies": {
38+
"lodash": "^4.17.21"
3639
}
3740
}

prompts.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,12 @@ module.exports = [
1010
type: 'confirm',
1111
default: false,
1212
message: 'Use scss?'
13+
},
14+
{
15+
when: answers => !!answers.useScss,
16+
name: 'injectAbstracts',
17+
type: 'confirm',
18+
default: false,
19+
message: 'Would you like to inject vars, functions and mixins in all SFC components?'
1320
}
1421
]

0 commit comments

Comments
 (0)