千呼万唤始出来!一键构建Vue-TypeScript应用

时间:2021-1-8 作者:admin

A simple TypeScript CLI for scaffolding Vue.js projects.

Installation

Prerequisites: Node.js (>=4.x, 6.x preferred), npm version 3+ and Git.

$ npm install -g vue-cli

Usage

vue init SimonZhangITer/vue-typescript-template <project-name>

Example:

$ vue init SimonZhangITer/vue-typescript-template my-project

The above command pulls the template from here, prompts for some information, and generates the project at ./my-project/.

Demo

i wrote a vue-typescript-demo project for practice, it recorded how I configured it and how to use vue.js with typescript

In Addition

vuex

add vuex option at initialization time, it will create src/store folder, and it had configed, like this:

src
├──store
   ├──actions.ts
   ├──mutations.ts
   ├──getters.ts
   ├──types.ts

vue-class-component

add vue-class-componet by default, and vue perfect support for it, it will make your code more flat and beautiful, you will like it.

  • npm run dev: first-in-class development experience.

    • Webpack + vue-loader for single file Vue components.
    • State preserving hot-reload
    • State preserving compilation error overlay
    • Lint-on-save with ESLint
    • Source maps
  • npm run build: Production ready build.

    • JavaScript minified with UglifyJS v3.
    • HTML minified with html-minifier.
    • CSS across all components extracted into a single file and minified with cssnano.
    • Static assets compiled with version hashes for efficient long-term caching, and an auto-generated production index.html with proper URLs to these generated assets.
    • Use npm run build --reportto build with bundle size analytics.
  • npm run unit: Unit tests run in JSDOM with Jest, or in PhantomJS with Karma + Mocha + karma-webpack.

    • Supports ES2015+ in test files.
    • Easy mocking.
  • npm run e2e: End-to-end tests with Nightwatch.

    • Run tests in multiple browsers in parallel.
    • Works with one command out of the box:
      • Selenium and chromedriver dependencies automatically handled.
      • Automatically spawns the Selenium server.
声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎进行举报,并提供相关证据,工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。