Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import svelte component ommiting .svelte extension

Is there any possibility to configure rollup to import svelte components omitting .svelte extension ?

import MyComp from "path/MyComp"

MyComp file has .svelte extension

like image 216
colesico Avatar asked Nov 05 '19 16:11

colesico


1 Answers

You can add a resolver to your configuration with @rollup/plugin-node-resolve:

rollup.config.js

const resolve = require('@rollup/plugin-node-resolve'); // add this to the other requires

return {
   ... // the usual things like input, output, ...
   plugins: [
       resolve({
          extensions: ['.svelte', '.js']
       }),
       svelte(),
       ... // any other plugin you are running
   ]
};
like image 151
Stephane Vanraes Avatar answered Nov 20 '22 01:11

Stephane Vanraes