- Notifications
You must be signed in to change notification settings - Fork0
wthrajat/npm-in-webjar
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
git clone https://github.com/wthrajat/npm-in-webjar.git&&cd npm-in-webjar&& mvn clean install
The directorysrc/main/resources
is now an NPM project - like the one you probaby have worked on usually.
- Edit
src/main/resources/package.json
for the deps update cd src/main/resources
and runnpm install
- This will update
src/main/resources/package-lock.json
NOTE: Without this step, the updated version is not taken into account during the maven build.
exportdefaultfunctionhelloWorld(name :string){console.log("Hello "+name+"!");}exportdefaulthelloWorld;
require.config({paths:{'output':'$services.webjars.url('domain.org.name:npm-in-webjar','output.js')'}});require(['output'],function(output){console.log('Your output bundle has been loaded successfully!');name="Taylor Swift";bundle.helloWorld(name);// Prints: Hello Taylor Swift!});
- At first, maven copy
src/main/resources
totarget/webjar
- Then
npm ci
is run insidetarget/webjar
installing the dependencies by followingpackage-lock.json
- Then
npm run build
is run insidetarget/webjar
, producing the artifacts oftarget/webjar/dist
- At last, the content of
target/webjar/dist
is copied to the relevant directory to be included in the WebJar packaging.
This project is inspired fromManuel Leducs's webpack demo.
About
Module to enable usage of NPM packages and TS thru WebJars