my-project/
├── node_modules/
├── public/
│ ├── favicon.ico
│ └── index.html
├── src/
│ ├── assets/
│ │ └── logo.png
│ ├── components/
│ │ └── HelloWorld.vue
│ ├── App.vue
│ └── main.js
├── .gitignore
├── babel.config.js
├── package.json
├── README.md
└── webpack.config.js
my-project/
├── node_modules/
├── public/
│ ├── favicon.ico
│ └── index.html
├── src/
│ ├── assets/
│ │ └── logo.png
│ ├── components/
│ │ └── HelloWorld.vue
│ ├── App.vue
│ └── main.js
├── .gitignore
├── babel.config.js
├── package.json
├── README.md
└── vue.config.js
注意,PWA 模板中使用了 vue.config.js 文件来自定义 Vue CLI 的配置选项,而不是使用 webpack.config.js。
my-project/
├── node_modules/
├── public/
│ ├── favicon.ico
│ └── index.html
├── src/
│ ├── assets/
│ │ └── logo.png
│ ├── components/
│ │ └── HelloWorld.vue
│ ├── App.vue
│ ├── main.ts
│ └── shims-tsx.d.ts
├── .gitignore
├── babel.config.js
├── package.json
├── README.md
├── tsconfig.json
└── tslint.json
注意,TypeScript 模板中使用了 tsconfig.json 文件来配置 TypeScript 编译器的选项,而且 main.ts 文件被用作入口文件,替代了 main.js。
my-project/
├── node_modules/
├── public/
│ ├── favicon.ico
│ └── index.html
├── src/
│ ├── assets/
│ │ └── logo.png
│ ├── components/
│ │ └── HelloWorld.vue
│ ├── App.vue
│ └── main.js
├── .gitignore
├── babel.config.js
├── package.json
├── README.md
vue create my-project --preset @vue/cli-preset-typescript
cd my-project
npm run serve
或者 使用npm install -g @vue/cli vue create my-project 创建项目,在创建项目的过程中,会提示选择一个预设(Preset)。选择 Manually select features,然后选择 TypeScript,最后选择其他需要的功能即可。
Vue CLI v4.5.12
? Please pick a preset: Manually select features
? Check the features needed for your project: Choose Vue version, Babel, TS, PWA, Router, Vuex, CSS Pre-processors, Linter, Unit
? Choose a version of Vue.js that you want to start the project with 2.x
? Use class-style component syntax? Yes
? Use Babel alongside TypeScript (required for modern mode, auto-detected polyfills, transpiling JSX)? Yes
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Less
? Pick a linter / formatter config: Standard
? Pick additional lint features: Lint on save
? Pick a unit testing solution: Mocha
? Where do you prefer placing config for Babel, ESLint, etc.? In dedicated config files
? Save this as a preset for future projects? No
-----------------------------------
选自 https://blog.51cto.com/u_15127642/2875211
上一篇:有效的括号