Zaid-Ajaj / Feliz

A fresh retake of the React API in Fable and a collection of high-quality components to build React applications in F#, optimized for happiness
https://zaid-ajaj.github.io/Feliz/
MIT License
534 stars 78 forks source link

Add VS Code debug config in Feliz Template #317

Open TheDevKnight opened 3 years ago

TheDevKnight commented 3 years ago

Hi, would be very cool when you add the vs code settings for debugging with chrome. I have an app based on the template end get no working debugging experience πŸ˜•

Regards

Zaid-Ajaj commented 3 years ago

Hi there @TheDevKnight, I will check it out. I think you need to enable source maps in latest Fable. Will try to see how to make it work and come back to you πŸ˜‰

TheDevKnight commented 3 years ago

Hi @Zaid-Ajaj that would be great. Thank you ☺️

roboz0r commented 3 years ago

Should be resolved by this PR https://github.com/Zaid-Ajaj/Feliz/pull/330

Zaid-Ajaj commented 3 years ago

Sorry @roboz0r I rolled back the config in the template because of I changed webpack back to v4.x (due to #332) so this issue remains

babysnakes commented 2 years ago

I'm not a front-end developer - just played around with Feliz but I think I found a solution for this problem - it seems to work in my very simple use case:

Almost all of the #330 PR is relevant. I followed the following steps:

 pwsh  git diff .\webpack.config.js
diff --git a/webpack.config.js b/webpack.config.js
index 54dbd73..a1a07ae 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -127,6 +127,11 @@ module.exports = {
     // - file-loader: Moves files referenced in the code (fonts, images) into output folder
     module: {
         rules: [
+            {
+                test: /\.js$/,
+                enforce: "pre",
+                use: ["source-map-loader"],
+            },
             {
                 test: /\.(js|jsx)$/,
                 exclude: /node_modules/,

This change fixes both the link in console logs in the browser and enabled me to debug in vscode against the F# code.

In order to debug in VSCode you can just open the command pallet and select: Debug: Open Link it will launch a debug session and offer to save a task. In my case it generated the following launch.json file:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "msedge",
            "name": "Web Debug",
            "request": "launch",
            "url": "http://localhost:8080/"
        }
    ]
}

@Zaid-Ajaj , If you're ok with this change I can create a PR.

HTH.