Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add custom js file to JHipster

Tags:

jhipster

I'm trying to include a javascript file which is not available as bower.

So I copied it to src/main/webapp/content and referenced in index.html

In the DEV profile all is fine -- it works.

Now, after generating WAR file with the PROD profile, the custom.js file is not included in the WAR (tried to unpack -- file is not there).

I have discovered the gulp is merging all css and js files, did I miss a config for this?

When the app is loaded, the browser complains with 404 in the index.html -- js file not found.

How can I fix this? What is the right way to include JS (or CSS) file into JHipster app?

Thank you.

like image 475
Oleh Sky Avatar asked Dec 13 '25 02:12

Oleh Sky


1 Answers

JS are not expected to be in content folder.

For CSS, copy your file to src/main/webapp/content/css.

For JS, copy your file to src/main/webapp/app possibly in a dedicated sub folder.

You don't have to inject them in index.html, gulp will do it for you. I suppose you did not see it in dev profile because you were not running gulp serve as explained in the doc

like image 78
Gaël Marziou Avatar answered Dec 16 '25 21:12

Gaël Marziou



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!