@@ -31,18 +31,15 @@ module.exports = (api, opts, rootOpts) => {
3131 // adapted from https://github.com/Akryum/vue-cli-plugin-apollo/blob/master/generator/index.js#L68-L91
3232 api . onCreateComplete ( ( ) => {
3333 // Modify main.js
34- helpers . updateMain ( src => {
35- const vueImportIndex = src . findIndex ( line => line . match ( / ^ i m p o r t V u e / ) )
36-
37- src . splice ( vueImportIndex + 1 , 0 , 'import \'./plugins/bootstrap-vue\'' )
38-
39- return src
34+ helpers . updateFile ( api . resolve ( api . entryFile ) , srcLines => {
35+ const vueImportIndex = srcLines . findIndex ( line => line . match ( / ^ i m p o r t V u e / ) )
36+ srcLines . splice ( vueImportIndex + 1 , 0 , 'import \'./plugins/bootstrap-vue\'' )
4037 } )
4138
4239 if ( opts . useScss ) {
4340 //Modify App.vue (import bootstrap styles)
44- helpers . updateApp ( src => {
45- let styleBlockIndex = src . findIndex ( line => line . match ( / ^ < s t y l e / ) )
41+ helpers . updateFile ( api . resolve ( './ src/App.vue' ) , srcLines => {
42+ let styleBlockIndex = srcLines . findIndex ( line => line . match ( / ^ < s t y l e / ) )
4643
4744 if ( styleBlockIndex === - 1 ) { //no style block found
4845 //create it with lang scss
@@ -59,10 +56,8 @@ module.exports = (api, opts, rootOpts) => {
5956 }
6057 }
6158
62- const bootstrapImportString = `@import "~@/assets/scss/vendors/bootstrap-vue/index";\n `
59+ const bootstrapImportString = `@import "~@/assets/scss/vendors/bootstrap-vue/index";`
6360 src . splice ( styleBlockIndex + 1 , 0 , bootstrapImportString )
64-
65- return src
6661 } )
6762 }
6863
0 commit comments