Search code examples
angularnpmsystemjs

How to use npm and systemjs as a build tool in an Angular 2 app (RC 5)?


I know how to use gulp and systemjs to bundle the app (like compression, bundle,export to build folder, etc), but now my boss need just npm and systemjs to finish the job.I have no idea how to write custom script in package.json and use systemjs to load certain module.

I search my answers in this place, and most of them use gulp or webpack, but it doesn't fit my requirement.


Solution

  • You can write scripts in your package.json file:

    https://docs.npmjs.com/misc/scripts

    example file:

    {
        "name": "foo"
        , "config": {"port": "8080"}
        , "scripts": {"start": "node server.js"}
    }
    

    You can run your scripts simply by calling npm run start in this example.


    Some more reading on why you can use NPM:

    https://medium.freecodecamp.com/why-i-left-gulp-and-grunt-for-npm-scripts-3d6853dd22b8#.6fcj4vs8d