компонент import svelte без расширения .svelte

Есть ли возможность настроить накопительный пакет для импорта компактных компонентов без расширения .svelte?

import MyComp from "path/MyComp"

Файл MyComp имеет расширение .svelte


person colesico    schedule 05.11.2019    source источник


Ответы (1)


Вы можете добавить преобразователь в свою конфигурацию с помощью @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
   ]
};
person Stephane Vanraes    schedule 06.11.2019
comment
Также можно использовать плагин @ rollup / plugin-alias rollup.config.js javascript import path from 'path'; const projectRootDir = path.resolve(__dirname); export default { plugins: [ alias({ resolve: ['.svelte','.js'], entries: [ {find:'src', replacement:path.resolve(projectRootDir, "src")} ], }) ]} - person colesico; 06.11.2019