Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Module to enable usage of NPM packages and TS thru WebJars

NotificationsYou must be signed in to change notification settings

wthrajat/npm-in-webjar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to use

git clone https://github.com/wthrajat/npm-in-webjar.git&&cd npm-in-webjar&& mvn clean install

Development

The directorysrc/main/resources is now an NPM project - like the one you probaby have worked on usually.

Version upgrade

  1. Editsrc/main/resources/package.json for the deps update
  2. cd src/main/resources and runnpm install
  3. This will updatesrc/main/resources/package-lock.json

NOTE: Without this step, the updated version is not taken into account during the maven build.

Example ofsrc/main/resources/main.ts

exportdefaultfunctionhelloWorld(name :string){console.log("Hello "+name+"!");}exportdefaulthelloWorld;

Using the output bundle

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!});

How is the build done

  1. At first, maven copysrc/main/resources totarget/webjar
  2. Thennpm ci is run insidetarget/webjar installing the dependencies by followingpackage-lock.json
  3. Thennpm run build is run insidetarget/webjar, producing the artifacts oftarget/webjar/dist
  4. At last, the content oftarget/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

Topics

Resources

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp