Webpack - How to load non module scripts into global scope | window

前端 未结 2 1591
醉话见心
醉话见心 2020-12-09 05:05

so i have a few vendor files that i need to run from window scoped (it\'s a bunch of window scoped functions) plus i have some polyfills that i would like to bundle into the

2条回答
  •  独厮守ぢ
    2020-12-09 05:28

    script-loader should-not be used anymore. You can use raw-loader instead:

    npm install --save-dev raw-loader
    

    And:

    import('!!raw-loader!./nonModuleScript.js').then(rawModule => eval.call(null, rawModule.default));
    

    I'm using !! before raw-loader because I'm in the case described in the documentation:

    Adding !! to a request will disable all loaders specified in the configuration

提交回复
热议问题