简体   繁体   中英

Is there any method to automatically load webpack external files?

I organize my frontend project with commonjs like var $ = require('jquery'); and use webpack to bundle entry js files. I can use webpack's "externals" to exclude some third-party libraries like jquery, angular or others into the final bundle and i have to add some script tags to the html to load these files. Is there any method to automatically load these external files instead of adding script tags manually in the html file?

Webpack is a module bundler not a javascript loader. It package files from local disk and don't load files from the web (except its own chunks).

Use a javascript loader, ie script.js

var $script = require("scriptjs");
$script("//ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.min.js", function() {
// ...
});

For more information please refer to this issue on Webpack repo: https://github.com/webpack/webpack/issues/150

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM