Select to view content in your preferred language

Require javascript file with hash code

1242
4
10-17-2017 08:05 AM
EvelynHernandez
Frequent Contributor

I wanted to know if there is a way to use require with a js generated by webpack using the html-webpack-plugin in hash mode.

Right now i require my file like:

<script type="text/javascript">require(["js/app.js"], function (app) {});</script>

But the html generated by webpack plugin is giving me this:

<script type="text/javascript" src="/app.js?add154b89f3e48308da7"></script></body>

So, how i do it if my file has a hash integrated?

I tried already this:

<script type="text/javascript">require(["js/app.js?add154b89f3e48308da7"], function (app) {});</script>

But it didnt work.

Thanks for the help.

Tags (3)
0 Kudos
4 Replies
ThomasSolow
Frequent Contributor

I don't know much about this subject, but this looks possibly related: ArcGIS JSAPI setup build with Webpack for production (start reading from webpack.config.js) · GitHub 

0 Kudos
EvelynHernandez
Frequent Contributor

Yes. But they doesnt use the html webpack plugin.

0 Kudos
ReneRubalcava
Honored Contributor

I don't have time to fully test this but can you try add a paths for your dojoConfig.

var dojoConfig = {
  paths: {
    "app": "/app.js?add154b89f3e48308da"
  }
};‍‍‍‍‍

That might work, but not sure.

0 Kudos
EvelynHernandez
Frequent Contributor

I dont use dojo config, i integrate the lib using webpack.

externals: [
 function(context, request, callback) {
 if (/^dojo/.test(request) ||
 /^dojox/.test(request) ||
 /^dijit/.test(request) ||
 /^esri/.test(request)
 ) {
 return callback(null, "amd " + request);
 }
 callback();
 }
 ],
0 Kudos