导入 svelte 组件省略 .svelte 扩展

import svelte component ommiting .svelte extension

是否有可能配置 rollup 以导入 svelte 组件而忽略 .svelte 扩展?

import MyComp from "path/MyComp"

MyComp 文件有 .svelte 扩展名

您可以使用 @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
   ]
};