File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
packages/vite/src/node/plugins Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -174,9 +174,12 @@ export function assetPlugin(config: ResolvedConfig): Plugin {
174
174
const file = checkPublicFile ( id , config ) || cleanUrl ( id )
175
175
this . addWatchFile ( file )
176
176
// raw query, read file and return as string
177
- return `export default ${ JSON . stringify (
178
- await fsp . readFile ( file , 'utf-8' ) ,
179
- ) } `
177
+ return {
178
+ code : `export default ${ JSON . stringify (
179
+ await fsp . readFile ( file , 'utf-8' ) ,
180
+ ) } `,
181
+ moduleType : 'js' , // NOTE: needs to be set to avoid double `export default` in `?raw&.txt`s
182
+ }
180
183
}
181
184
182
185
if ( ! urlRE . test ( id ) && ! config . assetsInclude ( cleanUrl ( id ) ) ) {
@@ -207,6 +210,7 @@ export function assetPlugin(config: ResolvedConfig): Plugin {
207
210
? 'no-treeshake'
208
211
: false ,
209
212
meta : config . command === 'build' ? { 'vite:asset' : true } : undefined ,
213
+ moduleType : 'js' , // NOTE: needs to be set to avoid double `export default` in `.txt`s
210
214
}
211
215
} ,
212
216
You can’t perform that action at this time.
0 commit comments