8000 Automatically add JS/CSS to HTML files for CDN resources · Issue #754 · webpack/webpack · GitHub
[go: up one dir, main page]

8000
Skip to content
Automatically add JS/CSS to HTML files for CDN resources #754
@cowwoc

Description

@cowwoc

Currently, when loading resources from CDNs, you need to manually add <script> and <link> tags to the HTML file, exports to the Webpack configuration and require() to the code that uses it. This is error prone for transitive dependencies (users may forget to add a <script> or <link> tag). Example:

index.html depends on index.js which depends on chunk.js which depends on jquery.js. The author of index.js may forget to add <script> and <link> tags for chunk.js's dependencies. This quickly gets out of hand as soon as dependencies have their own dependencies.

The fact that chunk.js invokes require('./jquery.js') should cause a <script type='text/javascript' src='cdn/jquery.js'> to get added to index.html on their behalf. Similarly, the fact that chunk.js invokes require('./jquery.css') should cause a <link rel='stylesheet' type='text/css' href='cdn/jquery.css'/> to get added on their behalf.

In an ideal world I'd tell webpack (at build-time) what scripts to load asynchronously, but then have require('foo') resolve synchronously at runtime, and have the library loaded without exporting globals. I'm not fixated on any particular implementation details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0