@@ -3,30 +3,30 @@ module.exports = (api, opts, rootOpts) => {
33
44 api . extendPackage ( {
55 dependencies : {
6- 'bootstrap-vue' : '^2.17.3'
7- } ,
8- devDependencies : {
6+ 'bootstrap-vue' : '^2.17.3' ,
97 'bootstrap' : '^4.5.2' ,
108 'popper.js' : '^1.16.1' ,
11- 'portal-vue' : '^2.1.7' ,
9+ 'portal-vue' : '^2.1.7'
10+ } ,
11+ devDependencies : {
1212 'sass' : '^1.26.11' ,
1313 'sass-loader' : '^10.0.2' ,
1414 }
1515 } )
1616
1717 if ( opts . usePolyfill ) {
1818 api . extendPackage ( {
19- devDependencies : {
19+ dependencies : {
2020 '@babel/polyfill' : '^7.11.5' ,
2121 'mutationobserver-shim' : '^0.3.7'
2222 }
2323 } )
2424 }
2525
2626 // Render bootstrap-vue plugin file
27- api . render ( {
28- './src/plugins/bootstrap-vue.js' : '. /templates/default/src/plugins/bootstrap-vue.js'
29- } , opts )
27+ const templateName = opts . useScss ? 'scss' : 'default'
28+ api . render ( `. /templates/${ templateName } ` )
29+
3030
3131 // adapted from https://github.com/Akryum/vue-cli-plugin-apollo/blob/master/generator/index.js#L68-L91
3232 api . onCreateComplete ( ( ) => {
@@ -39,6 +39,36 @@ module.exports = (api, opts, rootOpts) => {
3939 return src
4040 } )
4141
42+ if ( opts . useScss ) {
43+
44+
45+ //Modify App.vue (import bootstrap styles)
46+ helpers . updateApp ( src => {
47+ let styleBlockIndex = src . findIndex ( line => line . match ( / ^ < s t y l e / ) )
48+
49+ if ( styleBlockIndex === - 1 ) { //no style block found
50+ //create it with lang scss
51+ src . push ( `<style lang="scss">` )
52+ src . push ( `</style>` )
53+
54+ styleBlockIndex = src . length - 2
55+ }
56+ else {
57+ //check if has the attr lang="scss"
58+ if ( ! src [ styleBlockIndex ] . includes ( 'lang="scss' ) ) {
59+ //if not, replace line with lang="scss"
60+ src [ styleBlockIndex ] = '<style lang="scss">'
61+ }
62+ }
63+
64+ const bootstrapImportString = `@import "~@/assets/scss/vendors/bootstrap-vue/index";\n`
65+ src . splice ( styleBlockIndex + 1 , 0 , bootstrapImportString )
66+
67+ return src
68+ } )
69+ }
70+
71+
4272 // Add polyfill
4373 if ( opts . usePolyfill ) {
4474 helpers . updateBabelConfig ( cfg => {
0 commit comments