From d12159d55f6a0fa16a72521219dc125ddb17a8c7 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Thu, 4 Nov 2021 21:49:21 +0100 Subject: [PATCH] :bug: Fix issues where the sourcemap wasn't properly set (fix #21) --- src/index.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 2f373a5..93578ad 100644 --- a/src/index.ts +++ b/src/index.ts @@ -232,6 +232,8 @@ export interface Options { export default function solidPlugin(options: Partial = {}): Plugin { let needHmr = false; + let replaceDev = false; + let projectRoot = process.cwd(); return { name: 'solid', @@ -239,7 +241,8 @@ export default function solidPlugin(options: Partial = {}): Plugin { config(userConfig, { command }): UserConfig { // We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode - const replaceDev = options.dev === true || (options.dev !== false && command === 'serve'); + replaceDev = options.dev === true || (options.dev !== false && command === 'serve'); + projectRoot = userConfig.root; // TODO: remove when fully removed from vite const legacyAlias = normalizeAliases(userConfig.alias); @@ -304,9 +307,16 @@ export default function solidPlugin(options: Partial = {}): Plugin { } const opts: TransformOptions = { + babelrc: false, + configFile: false, + root: projectRoot, filename: id, + sourceFileName: id, presets: [[solid, { ...solidOptions, ...(options.solid || {}) }]], plugins: needHmr ? [[solidRefresh, { bundler: 'vite' }]] : [], + sourceMaps: true, + // Vite handles sourcemap flattening + inputSourceMap: false as any, }; if (id.includes('tsx')) {