gpt4 book ai didi

javascript - 汇总未生成 typescript 源图

转载 作者:行者123 更新时间:2023-12-03 23:26:41 25 4
gpt4 key购买 nike

我正在使用带有 svelte + typescript + scss 的汇总。我的问题是我无法生成源 map 。
以下是我的汇总配置文件:

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我正在使用的代码。
任何帮助将不胜感激!

最佳答案

这对我有用:您需要设置 sourceMap: falsetypescript汇总插件选项。

export default {
input: 'src/main.ts',
output: {
sourcemap: true,
format: 'iife',
...
},
plugins: [
...
svelte(...),
typescript({ sourceMap: false }),
...
]
}
事实证明,汇总的源映射折叠器与 typescript 的插件源映射生成器冲突。这就是为什么它适用于 prod 构建但不适用于 dev 构建(因为最初它是 sourceMap: !production )。只需让 rollup 完成繁重的工作。

关于javascript - 汇总未生成 typescript 源图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63218218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com