FranckFreiburger / vue3-sfc-loader

Single File Component loader for Vue2 and Vue3. Load .vue files directly from your HTML. No node.js environment, no build step.
MIT License
1.03k stars 116 forks source link

Example with imported JSON #124

Closed paul-hammant closed 5 months ago

paul-hammant commented 2 years ago

Is your feature request related to a problem? Please describe.

i have looked through the examples and can't see the necessary options{} magic to allow import data from '/path/to/some.json'; to work.

Describe the solution you'd like

Automatic handling of JSON in a vue SFC. If not automatic, then the functions to add to options{}

Describe alternatives you've considered

Additional context

FranckFreiburger commented 5 months ago

Hi Paul, you just need to define a JSON handler in your options.handleModule

async handleModule(type, getContentData, path, options) {

  if ( type === '.json' )
    return JSON.parse(await getContentData(false));
},