是的。使用rollup-plugin-svelte和rollup-plugin-typescript,它应该可以工作。我现在在汇总文件中使用它,如下所示:
import commonjs from 'rollup-plugin-commonjs'
import replace from 'rollup-plugin-replace'
import resolve from 'rollup-plugin-node-resolve'
import svelte from 'rollup-plugin-svelte'
import typescript from 'rollup-plugin-typescript'
const path = require('path')
const fs = require('fs')
export default {
input: 'src/index.ts',
plugins: [
typescript(),
commonjs({
include: 'node_modules/**'
}),
resolve({
browser: true,
preferBuiltins: false // for url npm module; otherwise rollup assumes node
}),
// Replace is to shut up redux
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
svelte({
// By default, all .html and .svelte files are compiled
extensions: ['.my-custom-extension', '.html', '.svelte'],
// You can restrict which files are compiled
// using `include` and `exclude`
// include: 'src/components/**/*.html',
// By default, the client-side compiler is used. You
// can also use the server-side rendering compiler
// generate: 'ssr',
// Extract CSS into a separate file (recommended).
css: function (css) {
fs.writeFileSync('./dist/svelte.css', css)
}
})
],
output: {
format: 'iife',
file: path.join(__dirname, './dist/index_dist.js') // equivalent to --output
}
}