superglue icon indicating copy to clipboard operation
superglue copied to clipboard

Generate a jsconfig or tsconfig with paths set

Open jho406 opened this issue 1 year ago • 0 comments

When running rails superglue:install:web or rails generate scaffold post body:string --force --no-template-engine --superglue superglue_rails generates page components with import statements that uses relative links. For example, in application.js we import page components like ../../views/posts/index.js.

Adding a jsonconfig.json or a tsconfig.json would help to shorten those imports. For example:

{
  "compilerOptions": {
    "target": "ES2016",
    "module": "ESNext",
    "moduleResolution": "Bundler", // << you should enable this
    "esModuleInterop": true,
    "paths": {
      "@/*": ["./app/javascript/*"]
    }
  },
  "exclude": ["node_modules/**/*"]

Since this file is generated once, add it as part of the rails superglue:install:web run.

jho406 avatar May 03 '24 15:05 jho406