Lombiq/Helpful-Extensions

Extract inline javascript block into file, compile with Node.js Extensions, and register for usage (OSOE-476)

0liver opened this issue · 6 comments

See this comment here.

Can be started once OSOE-84 is done.

Jira issue

@0liver Where exactly would you like the new js file to be placed?

0liver commented

We usually place JavaScript files into the Assets\Scripts folder. Use a telling name, too. Use hyphens to separate words.

The nice thing about Assets\Scripts is that you won't need any manual configuration to get the compilation to work 😀

So i tried the obvious rookie stuff first: copied the script into a separate .js file in a newly created Assets/Scripts as asked (without the <script> tag in the js file ofc). After this i spent hours trying to register is in a similar way as it was in the TargetBlankFilter.cs. So i was pretty sure that the registering was not the problem. Then i tried to figure out if the pathing was the problem and no matter what paths i tried, didnt work. After all these failed attempts, now how i think this should work based on looking at other modules, is that there should be a wwwroot folder (which was absent, so i created one, the created one is ignored, im guessing from gitignore, not sure if this is a problem). Now i would need the script to be copied into wwwroot/scripts, so i can access it, in order to do that i needed a package.json, which was also absent, so i created one, then i basically copied a package.json from another module and changed, deleted a few unneccesary things. I also created a ResourceManagementOptionsConfiguration.cs to Define the script and set a URL, and used it in the Filters/Startup services.Configure(...). Then i also realised that the HelpfulExtensions might need a dependency to the NodeJs.Extensions, so i also added that, then i tried to build assets from command line which resulted in an error, "It doesnt't look like nodejs-extensions is installed." So im kinda out of ideas as to what i should be doing next, or where it couldve went south real quick. Any ideas/corrections/suggestions would be appreciated, if needed i could start screenshotting everything. Thanks in advance! @0liver @DemeSzabolcs

0liver commented

Please format your question into more easily digestible pieces. Use italics for file paths, code blocks for code and technical strings, bold text to highlight something important. Here's a list of guidelines: https://orcharddojo.net/orchard-resources/CoreLibrary/ContributionGuideLines. Also use headers where appropriate. Don't write prose.

Also, consider asking technical questions on Teams, where more people will be able to help you. Most problems are not tied to the concrete issue you're working on.

0liver commented

Fixed by #114.

0liver commented

I've created a follow-up issue for some more work on this: #116.