【发布时间】:2020-11-22 20:35:20
【问题描述】:
我正在使用带有 svelte + typescript + scss 的汇总。我的问题是我无法生成源地图。
以下是我的汇总配置文件:
import svelte from 'rollup-plugin-svelte'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import livereload from 'rollup-plugin-livereload'
import { terser } from 'rollup-plugin-terser'
import typescript from '@rollup/plugin-typescript'
import alias from '@rollup/plugin-alias'
const production = !process.env.ROLLUP_WATCH
const path = require('path').resolve(__dirname, 'src')
const svelteOptions = require('./svelte.config')
function serve() {
let server
function toExit() {
if (server) server.kill(0)
}
return {
writeBundle() {
if (server) return
server = require('child_process').spawn(
'yarn',
['run', 'start', '--', '--dev'],
{
stdio: ['ignore', 'inherit', 'inherit'],
shell: true,
}
)
process.on('SIGTERM', toExit)
process.on('exit', toExit)
},
}
}
export default {
input: 'src/main.ts',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js',
},
plugins: [
alias({
entries: [
{ find: '@app', replacement: `${path}` },
{ find: '@components', replacement: `${path}/components` },
{ find: '@includes', replacement: `${path}/includes` },
{ find: '@styles', replacement: `${path}/styles` },
{ find: '@pages', replacement: `${path}/pages` },
],
}),
svelte(svelteOptions),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ['svelte'],
}),
commonjs(),
typescript({ sourceMap: !production }),
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload('public'),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser(),
],
watch: {
clearScreen: false,
},
}
我不确定我到底做错了什么。这是我正在使用的代码的link。 任何帮助将不胜感激!
【问题讨论】:
-
我刚刚克隆了你的项目,运行了
npm run build,并得到了生成的打字稿源图。它输出bundle.js.map。你正在运行什么命令给你带来麻烦? -
@CarlosRoso 在 TS 文件中的 chrome 控制台上记录一些内容,然后单击行号以检查是否在 chrome 检查器中看到 TS 文件。 (我在这里描述了我的问题:github.com/sveltejs/template/issues/157)
标签: rollup