11module . exports = ( api , options ) => {
2- function findFileName ( files , name ) {
2+ function findFileInNamed ( files , name ) {
33 const searchName = `/${ name . toLowerCase ( ) } `
44 return Object . keys ( files ) . find ( fileName => fileName . toLowerCase ( ) . includes ( searchName ) )
55 }
@@ -18,27 +18,30 @@ module.exports = (api, options) => {
1818 api . render ( './templates' , options )
1919
2020 api . postProcessFiles ( files => {
21+ const importRelativePath = 'assets/styles/tailwind'
22+ delete files [ `src/${ importRelativePath } .css` ]
23+
2124 const searchName = 'App.vue'
22- const appFileName = findFileName ( files , searchName )
23- const importPath = 'assets/styles/tailwind.css '
25+ const appFileName = findFileInNamed ( files , searchName )
26+ const importExtension = 'postcss '
2427 if ( ! appFileName ) {
25- return api . exitLog ( `${ searchName } file not found. Please import '${ importPath } ' manually.` , 'error' )
28+ return api . exitLog ( `${ searchName } file not found. Please import '${ importRelativePath } ' manually.` , 'error' )
2629 }
2730 const appFileString = files [ appFileName ]
28- if ( appFileString . includes ( importPath ) ) {
31+ if ( appFileString . includes ( importRelativePath ) ) {
2932 return
3033 }
31- const mainFileString = files [ findFileName ( files , 'main.' ) ]
32- if ( mainFileString && mainFileString . includes ( importPath ) ) {
34+ const mainFileString = files [ findFileInNamed ( files , 'main.' ) ]
35+ if ( mainFileString && mainFileString . includes ( importRelativePath ) ) {
3336 return
3437 }
35- const importStatement = `\n@import '${ importPath } ';\n`
38+ const importStatement = `\n@import '${ importRelativePath } . ${ importExtension } ';\n`
3639 const lines = appFileString . split ( / \r ? \n / g)
3740 const styleIndex = lines . findIndex ( line => line . startsWith ( '<style' ) )
3841 if ( styleIndex !== - 1 ) {
3942 lines [ styleIndex ] += importStatement
4043 } else {
41- lines [ lines . length - 1 ] += `\n<style>${ importStatement } </style>\n`
44+ lines [ lines . length - 1 ] += `\n<style>${ importStatement } \n </style>\n`
4245 }
4346 files [ appFileName ] = lines . join ( '\n' )
4447 } )
0 commit comments