lostintangent / codeswing

VS Code extension for building web applications ("swings") using a interactive and editor-integrated coding environment
https://aka.ms/codeswing
MIT License
978 stars 48 forks source link

Request: Multiple File Support #31

Closed johnpapa closed 3 years ago

johnpapa commented 3 years ago

I see in the github repo's readme that you can add additional files. I'm thinking like the Svelte REPL where you can have multiple components.

How do you do that in CodeSwing (can you)?

I see an example in the readme but New Swing doesnt seem to do it how I thought (New Swing File?)

lunelson commented 3 years ago

I ran in to a related issue when trying to @import or @use an external Sass file, and looking at the code I can offer that with Sass' renderSync method you'd need to use the file parameter rather than data, so as to give the compiler a file-path reference point for imports. I would imagine a similar issue will exist for other language compilers

https://github.com/codespaces-contrib/codeswing/blob/197235fe5c0e5e72e6b9a3f4de2ba9f13d4a7376/src/preview/languages/stylesheet.ts#L37-L40

lostintangent commented 3 years ago

@lunelson Out of curiosity: are you trying to import a relative URL (another Sass file within the swing) or an HTTP-based URL? I just ask since HTTP-based imports should already work, since I believe Sass just passes them through to CSS.

lunelson commented 3 years ago

@lostintangent actually I was trying to @use a Sass file (@use is Sass 4.x syntax, replacing @import) from outside of the codeswing. My hope was that an arrangement like this would work, so I could write swings under the ./test directory of a Sass library that I'm developing, for example.

.
├── _utils.scss
├── utils.pug
├── utils.js
├── swing-a/
│   ├── script.js
│   ├── codeswing.json
│   ├── index.pug
│   └── style.scss
└── swing-b/
    ├── script.js
    ├── codeswing.json
    ├── index.pug
    └── style.scss
lostintangent commented 3 years ago

@lunelson Thanks for confirming that! I have a fix for that scenario, that I'll ship in just a bit 👍

lunelson commented 3 years ago

@lostintangent that's great news! I'll be looking out for it 😄

lostintangent commented 3 years ago

@lunelson This should now work in v0.0.12, which is publishing to the marketplace as we speak. Additionally, the CodeSwing tree view now allows you to add/upload/rename/delete files, so I'm going to close this as resolved, and we can open new/specific issues as appropriate. Thanks!