1

I'm working with an application that uses a custom builder to inject scripts into the head of the DOM. In this particular case, I need to reference a JS file that exists in an installed library from the webpack config of the main application.

The best solution I can come up with is to reference it like this in the app.config.js file but it seems a bit clunky. Is it possible to get the path to this file in a cleaner way?

{
    name: 'loader-thing',
    placement: 'HEAD',
    filename: path.resolve(__dirname, 'node_modules/my-package/src/assets/loader_static.js'),
},

The builder reads the file at this path and then injects it into the head...that probably needs some attention as well but for now I'd just like to know that my approach isn't stupid.

1 Answer 1

0

I asked a few dev friends and the conclusion was that this approach is fine but it would be preferable if the script could be included from a CDN or if the package itself could inject into the head.

Sign up to request clarification or add additional context in comments.

Comments

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.