Giter Site home page Giter Site logo

npm-in-webjar's Introduction

NPM in WebJar Generic badge Maven TypeScript GitHub license Npm

How to use

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

Development

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

Version upgrade

  1. Edit src/main/resources/package.json for the deps update
  2. cd src/main/resources and run npm install
  3. 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.

Example of src/main/resources/main.ts

    export default function helloWorld(name : string) {
    console.log("Hello " + name + "!");
}
    export default helloWorld;

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 copy src/main/resources to target/webjar
  2. Then npm ci is run inside target/webjar installing the dependencies by following package-lock.json
  3. Then npm run build is run inside target/webjar, producing the artifacts of target/webjar/dist
  4. 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 from Manuel Leducs's webpack demo.

npm-in-webjar's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.