@@ -76,27 +76,38 @@ async function compileJS(content, options) {
76
76
return res ;
77
77
}
78
78
79
+ function compileDefault ( code , options ) {
80
+ return {
81
+ code
82
+ } ;
83
+ }
84
+
79
85
async function compile ( file , options ) {
80
86
const { fileSuffix, target} = options ;
81
87
const buildConfig = options . _config || { } ;
82
- const cssCompiler = getFileCompiler ( compileStyle , buildConfig ) ;
83
- const jsCompiler = getFileCompiler ( compileJS , buildConfig ) ;
84
88
file . lang = path . extname ( file . path ) . substr ( 1 ) ;
85
89
86
- // h5 的没有编译 sfc 中的 style block, assets file 也先不编译保持一致
87
90
if ( isCSS ( file . path ) ) {
88
91
file . type = 'css' ;
89
92
file . path = changeExt ( file . path , fileSuffix . css ) ;
93
+ const cssCompiler = getFileCompiler ( compileStyle , buildConfig ) ;
90
94
await cssCompiler ( file , options ) ;
91
95
}
92
- if ( isJS ( file . path ) ) {
96
+ else if ( isJS ( file . path ) ) {
93
97
file . type = 'js' ;
94
98
// TODO: H5 支持 ts 文件编译
95
99
if ( target !== 'h5' ) {
96
100
file . path = changeExt ( file . path , fileSuffix . js ) ;
97
101
}
102
+ const jsCompiler = getFileCompiler ( compileJS , buildConfig ) ;
98
103
await jsCompiler ( file , options ) ;
99
104
}
105
+ else {
106
+ // for other files, use default compiler
107
+ const compiler = getFileCompiler ( compileDefault , buildConfig ) ;
108
+ await compiler ( file , options ) ;
109
+ }
110
+
100
111
return file ;
101
112
}
102
113
0 commit comments