How to start Angular2 project with minimum of required files using npm?

后端 未结 3 829
执念已碎
执念已碎 2020-12-28 19:31

I was following Angular2 quickstart and installed required libraries using Node package manager: https://angular.io/guide/quickstart

created a package.json:

相关标签:
3条回答
  • 2020-12-28 19:50

    You can use the cdn versions of those files and use node_modules in development and don't include them in production at all:

    <script src="https://rawgithub.com/systemjs/systemjs/0.19.6/dist/system.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.0/angular2-polyfills.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.0/Rx.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.0/angular2.dev.js"></script>
    

    Take a look at this question and the comments in the answers: Angular 2 required libraries

    Also this is the smallest package.json you can get away with (depending in your setup):

    { "dependencies": { "angular2": "2.0.0-beta.0", "systemjs": "0.19.6" } }

    I'm using Webstorm which starts its own server and compiles typescript on its own when it detects the tsconfig.json file.

    So if you don't have your own server you'll need to add the lite-server dependency, config and scripts, and if you don't have a ts compiler you'll have to add the typescript dependency and scripts as well:

    "devDependencies": { "typescript": "^1.7.3" },

    0 讨论(0)
  • 2020-12-28 19:53

    You can remove unnecessary dependencies from package.json. Also, dependencies declared in devDependencies section is not bundled when packaging for production.

    0 讨论(0)
  • 2020-12-28 20:07

    You could use ng new barebones-app --minimal

    0 讨论(0)
提交回复
热议问题