1

In vue/vite/rails stack sourcemap is completely off. Devtool showing incorrect line on error/debug. Can figure out what exactly causing issue.

vite.config.ts:

import {defineConfig} from "vite";
import rubyPlugin from "vite-plugin-ruby";
import vuePlugin from "@vitejs/plugin-vue";
import {nodePolyfills} from "vite-plugin-node-polyfills";
import * as requirePlugin from "vite-plugin-require";
import sassGlobImportPlugin from "vite-plugin-sass-glob-import";

export default defineConfig({
    build: {
        emptyOutDir: true,
        sourcemap: true
    },
    resolve: {
        alias: {
            ...
        },
        extensions: [".js", ".es6", ".ts",  ".json", ".vue"]
    },
    plugins: [
        rubyPlugin(),
        nodePolyfills(),
        vuePlugin({
            template: {
                compilerOptions: {
                    whitespace: "preserve"
                }
            }
        }),
        requirePlugin.default(),
        sassGlobImportPlugin(),
    ],
    clearScreen: false,
    optimizeDeps: {
        include: ["crypto"]
    }
});

Example Component:

<template>
    <div>
        Home Page
    </div>
</template>

<script>
    export default {
        name: "Home",
        mounted() {
            throw Error("This is error");
        },
    };
</script>

This is what it showing me in devtool:

enter image description here

enter image description here

Expect to show correct error line in devtool

1
  • Found issue but didn't find solution. Problem with vite-plugin-require Commented Nov 28, 2023 at 9:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.